PERFORCE change 106480 for review
Warner Losh
imp at FreeBSD.org
Thu Sep 21 17:20:23 PDT 2006
http://perforce.freebsd.org/chv.cgi?CH=106480
Change 106480 by imp at imp_lighthouse on 2006/09/22 00:19:32
Break out the board specific stuff from the more generic stuff.
There's still a lot of assumptions about hardware, but this
makes it easier to add new boards.
Affected files ...
.. //depot/projects/arm/src/sys/boot/arm/at91/boot2/Makefile#7 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#23 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/boot2/tsc_board.c#1 add
Differences ...
==== //depot/projects/arm/src/sys/boot/arm/at91/boot2/Makefile#7 (text+ko) ====
@@ -4,7 +4,7 @@
P=boot2
FILES=${P}
-SRCS=arm_init.S boot2.c ee.c
+SRCS=arm_init.S boot2.c tsc_board.c ee.c
NO_MAN=
LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg
OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
==== //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#23 (text+ko) ====
@@ -141,112 +141,16 @@
}
}
-#ifdef BOOT_TSC
-#define TSC_FPGA
-#endif
-
-#ifdef TSC_FPGA
-#include "at91rm9200.h"
-#include "spi_flash.h"
-#include "fpga.h"
-
-#define FPGA_OFFSET (15 * FLASH_PAGE_SIZE)
-#define FPGA_LEN (212608)
-
-char buffer[FPGA_LEN];
-
-const struct fpga main_fpga =
-{
- AT91C_BASE_PIOB, AT91C_PIO_PB0,
- AT91C_BASE_PIOC, AT91C_PIO_PC11,
- AT91C_BASE_PIOB, AT91C_PIO_PB2,
- AT91C_BASE_PIOC, AT91C_PIO_PC12
-};
-
-void
-fpga_load(void)
-{
- int len, off, i, offset;
- char *addr = buffer;
-
- len = FPGA_LEN;
- offset = FPGA_OFFSET;
- for (i = 0; i < len; i+= FLASH_PAGE_SIZE) {
- off = i + offset;
- SPI_ReadFlash(off, addr + i, FLASH_PAGE_SIZE);
- }
- fpga_init(&main_fpga);
- fpga_clear(&main_fpga);
- fpga_write_bytes(&main_fpga, addr, len);
- fpga_done(&main_fpga);
-}
-#endif
-
-#ifdef BOOT_TSC
-static void
-MacFromEE()
-{
- uint32_t sig;
-#if 0
- uint8_t euid64[8] = { 0x00, 0x30, 0x96, 0x20,
- 0x00, 0x00, 0x00, 0x05 };
-#endif
+// Each board has to provide one of these.
+void board_init(void);
-#if 0
- printf("writing...\n");
- sig = 0xaa55aa55;
- EEWrite(0, (uint8_t *)&sig, sizeof(sig));
- EEWrite(48, euid64, sizeof(euid64));
-#endif
- sig = 0;
- EERead(0, (uint8_t *)&sig, sizeof(sig));
- if (sig != 0xaa55aa55)
- return;
- EERead(48, mac, 3);
- EERead(48+5, mac+3, 3);
- printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0],
- mac[1], mac[2], mac[3], mac[4], mac[5]);
-}
-#endif
-
-#define XMODEM_DL
-#ifdef XMODEM_DL
-#define FLASH_OFFSET (0 * FLASH_PAGE_SIZE)
-#define FPGA_OFFSET (15 * FLASH_PAGE_SIZE)
-#define FPGA_LEN (212608)
-#define KERNEL_OFFSET (220 * FLASH_PAGE_SIZE)
-#define KERNEL_LEN (6 * 1024 * FLASH_PAGE_SIZE)
-
-static void
-UpdateFlash(int offset)
-{
- char *addr = (char *)0x20000000 + (1 << 20); /* Load to base + 1MB */
- int len, i, off;
-
- while ((len = xmodem_rx(addr)) == -1)
- continue;
- printf("\nDownloaded %u bytes.\n", len);
- for (i = 0; i < len; i+= FLASH_PAGE_SIZE) {
- off = i + offset;
- SPI_WriteFlash(off, addr + i, FLASH_PAGE_SIZE);
- }
-}
-#endif
-
int
main(void)
{
int autoboot, c = 0;
ino_t ino;
-#ifdef TSC_FPGA
- SPI_InitFlash();
- fpga_load();
-#endif
-#ifdef BOOT_TSC
- EEInit();
- MacFromEE();
-#endif
+ board_init();
EMAC_Init();
sdcard_init();
EMAC_SetMACAddress(mac);
@@ -282,7 +186,7 @@
xputchar('\a');
#ifdef XMODEM_DL
else if (*cmd == '*')
- UpdateFlash(FLASH_OFFSET);
+ Update();
else if (*cmd == '#')
reset();
#endif
More information about the p4-projects
mailing list