From: wdenk Date: Wed, 25 Oct 2000 12:04:06 +0000 (+0000) Subject: [Renamed EXTBDINFO -> CFG_EXTBDINFO; re-ordered bd_info struct] X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a186c86e3d6ec8daf06df12cf4d0cd1a757f571c;p=users%2Frw%2Fppcboot.git [Renamed EXTBDINFO -> CFG_EXTBDINFO; re-ordered bd_info struct] Modifications for 0.6.0: * Shifted all CFG_CMD_* definitions to a new include file "include/cmd_confdefs.h", which must be included in the include/config_xxx.h file after any definition of CONFIG_COMMANDS (because it defines CONFIG_COMMAND if it isn't defined already), but before testing the value of CONFIG_COMMANDS in any #ifs. * Fixed Cogent support. * To allow for platform specific make options, we added two new make variables: PLATFORM_RELFLAGS and PLATFORM_CPPFLAGS. They are initially set empty, and are included in the definitions of RELFLAGS and CPPFLAGS in the top level config.mk file. After making this change, it no longer made sense to have things like #ifdef CONFIG_8xx or CONFIG_4xx etc in the top level config.mk file - so I moved each of the platform dependent flags into the various subdirectory config.mk files. * Modified Makefiles (hard wired lib names; avoi unnecessary sub directory builds) * Replaced CFG_FLASH_BASE by CFG_MONITOR_BASE when dealing with the location of the monitor code for systems that boot from EPROM, but have FLASH somewhere else. * Added CFG_FLASH_ENV_ADDR for systems where monitor and environment are in different memory regions. * Added CFG_FLASH_ENV_BUF for systems with very large flash sectors, where you cannot reserve a whole sector for the environment (well, you could store the Linux kernel as environemnt variable then :-) * Added watchdog support (this will need sppropiate changes in the Linux kernel, too!) * Added command to boot from a partition on an IDE device * Improved IDE support * Added support for MacOS / LinuxPPC compatible partitions on IDE devices * Added support for MBX8xx boards (unfinished, work in progress! - thanks to Marius Gröger) * Added list handling into 'common/list.c' * Added devices support into 'common/devices.c' (now used to install console devices and redirect stdin, stdout and stderr) * Detected keypress while showing the help * Minimized the console structures * Use a dynamic way to redirect the console input, output and error using environment variables (stdin, stdout, stderr). The list of available console devices is printed using the 'coninfo' command. Supported console drivers are "serial" (buildin) & "video". Who want to add the LCD console driver? Read the README.CONSOLE for more infos. * Some commands default to the "last used address" so that for instance a "bootp" could be followed by a plain "iminfo" or "bootm" (without arguments) using the memory address used by the previous (here bootp) command. * Rewrite the commandline parser (added a 'repeatable' field to the command structure) * The command separator ';' now can be used in interactive commands, too * Changed console support to use a global variable that points to the bd_t structure instead of old bi_mon_fnc_ptr. All console functions called before relocation will be replaced with the serial functions on linking. * Now printenv prints environment size, too * Added BOOTP environment variables (when received) * Added bash-like MACRO support using the syntax "$(envname)". Then you can boot the linux kernel by using this simple command: bootp; setenv bootargs root=/dev/nfs nfsroot=$(serverip): \ $(rootpath) ip=$(ipaddr):$(serverip):$(gatewayip):$(subnetmask): \ $(hostname):eth0:off; bootm * Extended BOOTP features. Now we have more network parameters from the server in net/net.c: subnet mask, gateways ip, NIS domain, hostname, bootfile size & root path. More can be added by looking at the RFC1048. * Added tab emulation on video_putc. * Fixed FADS823 pcmcia support. Changed PCMCIA driver to support 3.3V pcmcia cards on the 5V keyed socket. * Added a custom board configuration (GENIETV). * Added AD7177 video encoder support. * Added NTSC support to video controller (untested). * Added putc, getc, puts and tstc functions. * Hacked a bug into /tools/easylogo.c * Some changes to CPCI405 code (by Stefan Roese): added CONFIG_NVRAM_ENV so that environment variables are no longer in flash, but in NVRAM (this needs some more defines like base address and size of the NVRAM); also, the environment is CRC checked * Some fixes to ATA support, added LinuxPPC partition awareness * Tested (and fixed) FPS850L configuration * Added ethernet support for FADS860T (thanks to Christian Vejlbo) --- diff --git a/common/board.c b/common/board.c index d9225d0..3812b17 100644 --- a/common/board.c +++ b/common/board.c @@ -24,15 +24,13 @@ #include #include #include +#include #if (CONFIG_COMMANDS & CFG_CMD_IDE) #include #endif #if (CONFIG_COMMANDS & CFG_CMD_KGDB) #include #endif -#ifdef CONFIG_VIDEO -#include -#endif #include static char *failed = "*** failed ***\n"; @@ -103,6 +101,10 @@ board_init_f (ulong bootflag) /* set up serial port */ serial_init (clock_mhz, baudrate); + /* Initialize the console (before the relocation) */ + console_init_f (); + + /* now we can use standard printf/puts/getc/tstc functions */ display_options(); printf ("Initializing...\n CPU: "); /* Check CPU */ @@ -119,6 +121,14 @@ board_init_f (ulong bootflag) hang(); } +#ifdef CONFIG_COGENT + /* miscellaneous platform dependent initialisations */ + if (misc_init_f() < 0) { + printf (failed); + hang(); + } +#endif + /* Map bank 4: SRAM */ printf (" DRAM: "); @@ -136,7 +146,7 @@ board_init_f (ulong bootflag) * * First reserve memory for monitor code at end of DRAM. */ - len = get_endaddr() - CFG_FLASH_BASE; + len = get_endaddr() - CFG_MONITOR_BASE; if (len > CFG_MONITOR_LEN) { printf ("*** PPCBoot size %ld > reserved memory (%d)\n", len, CFG_MONITOR_LEN); @@ -167,19 +177,35 @@ board_init_f (ulong bootflag) addr_sp = (ulong)bd - 128; addr_sp &= ~0xF; +#if defined(CFG_FLASH_ENV_BUF) + /* + * Unfortunately, some boards (like the Cogent CMA302 flash I/O + * Module) have ridiculously large sectors (512KB) because they + * have 8 x 8 bit wide flash chips arranged so that each chip has + * one of the byte lanes in a 64 bit word. Not only that, the + * Intel 28F008S5 flash chips have 64K sectors (16 of them, for + * 1Mbyte each). So effectively, the CMA302 has 16 x 512KB + * sectors. We need some space to store the data when programming + * one of these flash sectors, so the only way I can think of at + * the moment is to allocate it here, between the board data and + * the top of the stack. + */ + addr_sp -= CFG_FLASH_ENV_BUF; +#endif /* CFG_FLASH_ENV_BUF */ + /* * Save local variables to board info struct */ -#ifdef EXTBDINFO - strcpy(bd->bi_s_version, "1.1"); - strcpy(bd->bi_r_version, PPCBOOT_VERSION); -#endif bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ bd->bi_memsize = dram_size; /* size of DRAM memory in bytes */ bd->bi_flashstart = CFG_FLASH_BASE; /* start of FLASH memory */ bd->bi_flashsize = 0; /* size of FLASH memory (PRELIM) */ +#if CFG_MONITOR_BASE == CFG_FLASH_BASE bd->bi_flashoffset = CFG_MONITOR_LEN; /* reserved area for startup monitor */ +#else + bd->bi_flashoffset = 0; +#endif bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */ bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */ #ifdef CONFIG_8xx @@ -207,10 +233,14 @@ board_init_f (ulong bootflag) bd->bi_intfreq = clock_mhz; /* Internal Freq, in MHz */ bd->bi_busfreq = get_bus_freq(clock_mhz); /* Bus Freq, in MHz */ bd->bi_baudrate = baudrate; /* Console Baudrate */ -#ifdef EXTBDINFO - bd->bi_procfreq = bd->bi_intfreq * 1000000; /* Processor Speed, In Hz */ - bd->bi_plb_busfreq = bd->bi_busfreq; - bd->bi_pci_busfreq = bd->bi_busfreq; + +#ifdef CFG_EXTBDINFO + strncpy(bd->bi_s_version, "1.2", sizeof(bd->bi_s_version)); + strncpy(bd->bi_r_version, PPCBOOT_VERSION, sizeof(bd->bi_r_version)); + + bd->bi_procfreq = bd->bi_intfreq * 1000000; /* Processor Speed, In Hz */ + bd->bi_plb_busfreq = bd->bi_busfreq; + bd->bi_pci_busfreq = bd->bi_busfreq; #endif /* Function pointers must be added after code relocation */ @@ -235,9 +265,17 @@ void board_init_r (bd_t *bd, ulong dest_addr) { cmd_tbl_t *cmdtp; ulong flash_size; - ulong reloc_off = dest_addr - CFG_FLASH_BASE; + ulong reloc_off = dest_addr - CFG_MONITOR_BASE; + /* Pointer to initial global data area */ + init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); extern void malloc_bin_reloc (ulong); + + /* Save a global pointer to the board info struct */ + bd_ptr = bd ; + /* Set the monitor function pointer to DPAM init data */ + bd->bi_mon_fnc = &idata->bi_mon_fnc; + /* * We have to relocate the command table manually */ @@ -281,9 +319,53 @@ void board_init_r (bd_t *bd, ulong dest_addr) } bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ +#if defined(CFG_FLASH_ENV_ADDR) + /* + * Protect the sector that the environment is in. + * + * This scheme (i.e. bi_flashoffset in the board info) cannot + * really reflect an arbitrarily placed environment flash sector, + * but lets just do our best, and assume that if CFG_FLASH_ENV_ADDR + * is defined it will be in a sensible location e.g. either the + * first sector, or the sector just after the monitor, if it is + * in flash. + */ + { + ulong addr, newoff; + flash_info_t *fip; + int i, j; + + /* address of last byte in the environment */ + addr = CFG_FLASH_ENV_ADDR + CFG_FLASH_ENV_SIZE - 1; + + /* make sure it is within the flash */ + if ((fip = addr2info(addr)) == NULL) + panic("environment address 0x%08lx is not within flash!\n", addr); + + /* move it to the sector boundary */ + for (i = 0, j = 1; j < fip->sector_count; i++, j++) + if (addr >= fip->start[i] && addr < fip->start[j]) + break; + if (j == fip->sector_count) + addr = fip->start[0] + fip->size; + else + addr = fip->start[j]; + + /* adjust flashoffset if required */ + newoff = addr - bd->bi_flashstart; + if (bd->bi_flashoffset < newoff) + bd->bi_flashoffset = newoff; + } +#endif + /* initialize higher level parts of CPU like time base and timers */ cpu_init_r (bd); +#ifdef CONFIG_COGENT + /* miscellaneous platform dependent initialisations */ + misc_init_r(bd); +#endif + #ifdef CONFIG_SPD823TS reset_phy (); #endif @@ -307,46 +389,44 @@ void board_init_r (bd_t *bd, ulong dest_addr) /* Insert function pointers now that we have relocated the code */ - bd->bi_mon_fnc.getc = serial_getc; - bd->bi_mon_fnc.tstc = serial_tstc; - bd->bi_mon_fnc.putc = serial_putc; - bd->bi_mon_fnc.putstr = serial_putstr; - bd->bi_mon_fnc.printf = printf; - #if defined(CONFIG_8xx) - bd->bi_mon_fnc.install_hdlr = cpm_install_handler; - bd->bi_mon_fnc.free_hdlr = cpm_free_handler; + bd->bi_mon_fnc->install_hdlr = cpm_install_handler; + bd->bi_mon_fnc->free_hdlr = cpm_free_handler; #elif defined(CONFIG_4xx) - bd->bi_mon_fnc.install_hdlr = irq_install_handler; - bd->bi_mon_fnc.free_hdlr = irq_free_handler; + bd->bi_mon_fnc->install_hdlr = irq_install_handler; + bd->bi_mon_fnc->free_hdlr = irq_free_handler; #else #error No interrupt handler for this architecture #endif /* Initialize other board modules */ -#ifdef CONFIG_VIDEO - printf(" Video: "); - video_init(CONFIG_VIDEO_ADDR); -#endif #ifdef CONFIG_PCMCIA printf(" PCMCIA: "); pcmcia_init(); #endif - bd->bi_mon_fnc.malloc = malloc; - bd->bi_mon_fnc.free = free; + bd->bi_mon_fnc->malloc = malloc; + bd->bi_mon_fnc->free = free; /* initialize malloc() area */ mem_malloc_init (dest_addr); malloc_bin_reloc (reloc_off); +/** LEAVE THIS HERE **/ + /* Initialize devices */ + devices_init(); + + /* Initialize the console (after the relocation and devices init) */ + console_init_r (); + putc('\n'); +/**********************/ + /* Initialization complete - start the monitor */ main_loop (bd); /* NOTREACHED - start_main does not return; just in case: loop here */ - for (;;) - ; + for (;;); } void hang(void) diff --git a/include/config_CPCI405.h b/include/config_CPCI405.h index 56e37da..5d9c6de 100644 --- a/include/config_CPCI405.h +++ b/include/config_CPCI405.h @@ -68,11 +68,12 @@ #define CONFIG_PCI_PNP 1 /* include pci plug-and-play */ -#define CONFIG_DRAM_SPEED (CONFIG_BUSCLOCK) /* MHz */ - #define CONFIG_COMMANDS \ ((CONFIG_CMD_DFL | CFG_CMD_PCI | CFG_CMD_IRQ) & ~(CFG_CMD_ENV)) +/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ +#include + #define CONFIG_NVRAM_ENV 1 /* use NVRAM for environment vars */ #define CFG_NVRAM_BASE_ADDR 0xf0200000 /* NVRAM base address */ #define CFG_NVRAM_SIZE (32*1024) /* NVRAM size */ @@ -81,12 +82,14 @@ (CFG_NVRAM_BASE_ADDR+CFG_NVRAM_SIZE-CFG_NVRAM_ENV_SIZE-4) /* Env */ #define CFG_NVRAM_VAR_CRC_ADDR (CFG_NVRAM_VAR_ADDR+CFG_NVRAM_ENV_SIZE) +#undef CONFIG_WATCHDOG /* watchdog disabled */ + /* * Miscellaneous configurable options */ #define CFG_LONGHELP /* undef to save memory */ #define CFG_PROMPT "=> " /* Monitor Command Prompt */ -#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG) +#if (CONFIG_COMMANDS & CFG_CMD_KGDB) #define CFG_CBSIZE 1024 /* Console I/O Buffer Size */ #else #define CFG_CBSIZE 256 /* Console I/O Buffer Size */ @@ -98,12 +101,12 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_BAUDRATE_MIN 300 /* lowest possible baudrate */ -#define CFG_BAUDRATE_MAX 115200 /* highest possible baudrate */ +#define CFG_BAUDRATE_MIN 300 /* lowest possible baudrate */ +#define CFG_BAUDRATE_MAX 115200 /* highest possible baudrate */ #define CFG_BAUDRATE_DEFAULT CONFIG_BAUDRATE /* default baudrate */ #define CFG_TFTP_LOADADDR 0x100000 /* default load address */ -#define EXTBDINFO 1 /* To use extended board_into (bd_t) */ +#define CFG_EXTBDINFO 1 /* To use extended board_into (bd_t) */ /*----------------------------------------------------------------------- * Start addresses for the final memory configuration @@ -116,6 +119,7 @@ #else #define CFG_FLASH_BASE 0x00FE0000 #endif +#define CFG_MONITOR_BASE CFG_FLASH_BASE #define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */ #define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */ @@ -141,6 +145,9 @@ * Cache Configuration */ #define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */ +#if (CONFIG_COMMANDS & CFG_CMD_KGDB) +#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */ +#endif /* * Init Memory Controller: diff --git a/include/ppcboot.h b/include/ppcboot.h index ca5afa6..642da81 100644 --- a/include/ppcboot.h +++ b/include/ppcboot.h @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef CONFIG_8xx #include #endif @@ -40,6 +41,7 @@ typedef unsigned char uchar; typedef volatile unsigned long vu_long; #include +#include #ifdef DEBUG #define debug(fmt,args...) printf (fmt ,##args) @@ -53,7 +55,7 @@ typedef struct monitor_functions { int (*getc)(void); int (*tstc)(void); void (*putc)(const char c); - void (*putstr)(const char *s); + void (*puts)(const char *s); void (*printf)(const char *fmt, ...); void (*install_hdlr)(int, interrupt_handler_t *, void *); void (*free_hdlr)(int); @@ -65,35 +67,33 @@ typedef struct monitor_functions { * ppcboot starts it up. */ typedef struct bd_info { -#ifdef EXTBDINFO - unsigned char bi_s_version[4]; /* Version of this structure */ - unsigned char bi_r_version[30]; /* Version of the ROM (IBM) */ +#ifdef CFG_EXTBDINFO + unsigned char bi_s_version[4]; /* Version of this structure */ #endif - unsigned long bi_memstart; /* start of DRAM memory */ - unsigned long bi_memsize; /* size of DRAM memory in bytes */ - unsigned long bi_flashstart; /* start of FLASH memory */ - unsigned long bi_flashsize; /* size of FLASH memory */ - unsigned long bi_flashoffset; /* reserved area for startup monitor */ - unsigned long bi_sramstart; /* start of SRAM memory */ - unsigned long bi_sramsize; /* size of SRAM memory */ + unsigned long bi_memstart; /* start of DRAM memory */ + unsigned long bi_memsize; /* size of DRAM memory in bytes */ + unsigned long bi_flashstart; /* start of FLASH memory */ + unsigned long bi_flashsize; /* size of FLASH memory */ + unsigned long bi_flashoffset; /* reserved area for startup monitor */ + unsigned long bi_sramstart; /* start of SRAM memory */ + unsigned long bi_sramsize; /* size of SRAM memory */ #ifdef CONFIG_8xx - unsigned long bi_immr_base; /* base of IMMR register */ + unsigned long bi_immr_base; /* base of IMMR register */ #endif - unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ - unsigned long bi_ip_addr; /* IP Address */ - unsigned char bi_enetaddr[6]; /* Ethernet adress */ - unsigned char bi_reserved[2]; /* -- just for alignment -- */ - unsigned long bi_intfreq; /* Internal Freq, in MHz */ -#ifdef EXTBDINFO - unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */ + unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */ + unsigned long bi_ip_addr; /* IP Address */ + unsigned char bi_enetaddr[6]; /* Ethernet adress */ + unsigned char bi_reserved[2]; /* -- just for alignment -- */ + unsigned long bi_intfreq; /* Internal Freq, in MHz */ + unsigned long bi_busfreq; /* Bus Freq, in MHz */ + unsigned long bi_baudrate; /* Console Baudrate */ +#ifdef CFG_EXTBDINFO + unsigned char bi_r_version[32]; /* Version of the ROM (IBM) */ + unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */ + unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */ + unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */ #endif - unsigned long bi_busfreq; /* Bus Freq, in MHz */ -#ifdef EXTBDINFO - unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */ - unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */ -#endif - unsigned long bi_baudrate; /* Console Baudrate */ - mon_fnc_t bi_mon_fnc; /* Addresses of monitor functions */ + mon_fnc_t *bi_mon_fnc; /* Pointer to monitor functions */ } bd_t; /* The following data structure is placed in DPRAM to allow for a @@ -101,10 +101,12 @@ typedef struct bd_info { * (until we have set up the memory controller so that we can use * RAM). * - * Keep it *SMALL*! + * Keep it *SMALL* and remember to set CFG_INIT_DATA_SIZE > sizeof(init_data_t) */ typedef struct init_data { unsigned long cpu_speed; /* VCOOUT = CPU clock in Hz! */ + unsigned long relocated; /* Set when relocated to RAM */ + mon_fnc_t bi_mon_fnc; /* Monitor functions */ } init_data_t; /* @@ -130,9 +132,17 @@ int set_board_info(bd_t *, uint); int checkboard (void); int checkflash (void); int checkdram (void); +#if defined(CONFIG_COGENT) +int misc_init_f (void); +void misc_init_r (bd_t *); +#endif /* CONFIG_COGENT */ + +/* common/cmd_bootm.c */ +void print_image_hdr (image_header_t *hdr); /* common/cmd_nvedit.c */ -char *getenv (uchar *); +char *getenv (uchar *); +void inline setenv (char *, char *); /* board/flash.c */ ulong flash_get_size (vu_long *addr, flash_info_t *info); @@ -153,7 +163,7 @@ void reset_phy (void); void serial_init (ulong, int); void serial_setbrg (ulong, int); void serial_putc (const char); -void serial_putstr (const char *); +void serial_puts (const char *); void serial_addr (unsigned int); int serial_getc (void); int serial_tstc (void); @@ -201,6 +211,9 @@ int checkicache (void); int checkdcache (void); void upmconfig (unsigned int, unsigned int *, unsigned int); void udelay (unsigned long); +#if defined(CONFIG_WATCHDOG) +void watchdog_reset(void); +#endif /* CONFIG_WATCHDOG */ /* $(CPU)/speed.c */ ulong get_gclk_freq (void); @@ -239,11 +252,61 @@ int disable_interrupts (void); /* ppc/vsprintf.c */ ulong simple_strtoul(const char *cp,char **endp,unsigned int base); long simple_strtol(const char *cp,char **endp,unsigned int base); -void printf(const char *fmt, ...); void panic(const char *fmt, ...); int sprintf(char * buf, const char *fmt, ...); +int vsprintf(char *buf, const char *fmt, va_list args); /* ppc/crc32.c */ ulong crc32 (ulong, const unsigned char *, uint); +/* disk/part_mac.c */ +void print_part_mac (int); + +/* common/console.c */ +bd_t *bd_ptr ; + +void console_init_f(void); /* Before relocation; uses the serial stuff */ +void console_init_r(void); /* After relocation; uses the console stuff */ +int console_assign (int file, char *devname); /* Assign the console */ + +/* + * STDIO based functions (can always be used) + */ + +/* serial stuff */ +void serial_printf (const char *fmt, ...); + +/* stdin */ +int getc(void); +int tstc(void); + +/* stdout */ +void putc(const char c); +void puts(const char *s); +void printf(const char *fmt, ...); + +/* stderr */ +#define eputc(c) fputc(stderr, c) +#define eputs(s) fputs(stderr, s) +#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args) + +/* + * FILE based functions (can only be used AFTER relocation!) + */ + +#define stdin 0 +#define stdout 1 +#define stderr 2 +#define MAX_FILES 3 + +void fprintf(int file, const char *fmt, ...); +void fputs(int file, const char *s); +void fputc(int file, const char c); +int ftstc(int file); +int fgetc(int file); + +#ifdef CONFIG_PCMCIA +int pcmcia_init (void); +#endif + #endif /* _PPCBOOT_H_ */