From: wdenk Date: Sat, 3 Nov 2001 22:21:12 +0000 (+0000) Subject: * Add LCD driver for MPC823; X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b81e9fde1b0b8e4dec0873e2ecd1e8f39e6f91fa;p=users%2Frw%2Fppcboot.git * Add LCD driver for MPC823; changed initialization sequence to get display early. * Minor code reordering, cleanup and reformatting * Fix bug in cpu/mpc8xx/i2c.c: when used to read environment from EEPROM, it tries to access serial console before port was initialized Patch by David Petersen, 2 Nov 2001 --- diff --git a/CHANGELOG b/CHANGELOG index 277032d..3b1dba7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -56,6 +56,19 @@ To do: Modifications for 1.1.0: ====================================================================== +* Add LCD driver for MPC823; + changed initialization sequence to get display early. + +* Minor code reordering, cleanup and reformatting + +* Fix bug in cpu/mpc8xx/i2c.c: when used to read environment from + EEPROM, it tries to access serial console before port was + initialized + Patch by David Petersen, 2 Nov 2001 + +* Fix bug in cpu/mpc8240/cpu_init.c + Patch by Jim Thompson, 25 Oct 2001 + * Several patches by Erik Theisen, 14 Oct 2001: - Fix udelay() for longer delays - Fix wait_ticks() - don't treat timebase registers as signed diff --git a/Makefile b/Makefile index 850dfe7..bd0ed17 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,7 @@ export ARCH CPU BOARD VENDOR # load other configuration include $(TOPDIR)/config.mk +# The "tools" are needed early, so put this first SUBDIRS = tools \ $(ARCH) \ cpu/$(CPU) \ @@ -85,7 +86,7 @@ OBJS += common/libcommon.a ######################################################################### -all: ppcboot.srec ppcboot.bin +all: ppcboot.srec ppcboot.bin System.map install: all cp ppcboot.bin /tftpboot/ppcboot.bin @@ -114,6 +115,11 @@ etags: etags -a `find $(SUBDIRS) include \ \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)` +System.map: ppcboot + @$(NM) $< | \ + grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ + sort > System.map + ######################################################################### else all install ppcboot ppcboot.srec depend dep: @@ -566,7 +572,7 @@ clean: | xargs rm -f rm -f examples/hello_world examples/timer rm -f tools/img2srec tools/mkimage tools/envcrc tools/gen_eth_addr - rm -f tools/easylogo/easylogo + rm -f tools/easylogo/easylogo tools/bmp_logo rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend clobber: clean @@ -576,7 +582,7 @@ clobber: clean | xargs rm -f rm -f $(OBJS) *.bak tags TAGS rm -fr *.*~ - rm -f ppcboot ppcboot.bin ppcboot.elf ppcboot.srec ppcboot.map + rm -f ppcboot ppcboot.bin ppcboot.elf ppcboot.srec ppcboot.map System.map rm -f tools/crc32.c tools/environment.S mrproper \ diff --git a/board/sandpoint/ns16550.c b/board/sandpoint/ns16550.c index dd83311..2f04a26 100644 --- a/board/sandpoint/ns16550.c +++ b/board/sandpoint/ns16550.c @@ -7,58 +7,56 @@ #include #include "ns16550.h" -#define LCRVAL LCR_8N1 /* 8 data, 1 stop, no parity */ +#define LCRVAL LCR_8N1 /* 8 data, 1 stop, no parity */ #define MCRVAL (MCR_DTR | MCR_RTS) /* RTS/DTR */ #define FCRVAL (FCR_FIFO_EN | FCR_RXSR | FCR_TXSR) /* Clear & enable FIFOs */ typedef struct NS16550 *NS16550_t; -static const NS16550_t COM_PORTS[2] = - {(NS16550_t) (CFG_ISA_IO + COM1), (NS16550_t) (CFG_ISA_IO + COM2)}; +static const NS16550_t COM_PORTS[2] = { + (NS16550_t) (CFG_ISA_IO + COM1), + (NS16550_t) (CFG_ISA_IO + COM2), +}; -volatile struct NS16550 * -NS16550_init(int chan, int baud_divisor) +volatile struct NS16550 *NS16550_init (int chan, int baud_divisor) { - volatile struct NS16550 *com_port; - com_port = (struct NS16550 *) COM_PORTS[chan]; - com_port->ier = 0x00; - com_port->lcr = LCR_BKSE | LCRVAL; - com_port->dll = baud_divisor & 0xff; - com_port->dlm = (baud_divisor >> 8) & 0xff; - com_port->lcr = LCRVAL; - com_port->mcr = MCRVAL; - com_port->fcr = FCRVAL; - return (com_port); + volatile struct NS16550 *com_port; + + com_port = (struct NS16550 *) COM_PORTS[chan]; + com_port->ier = 0x00; + com_port->lcr = LCR_BKSE | LCRVAL; + com_port->dll = baud_divisor & 0xff; + com_port->dlm = (baud_divisor >> 8) & 0xff; + com_port->lcr = LCRVAL; + com_port->mcr = MCRVAL; + com_port->fcr = FCRVAL; + return (com_port); } -void -NS16550_reinit(volatile struct NS16550 *com_port, int baud_divisor) +void NS16550_reinit (volatile struct NS16550 *com_port, int baud_divisor) { - com_port->ier = 0x00; - com_port->lcr = LCR_BKSE; - com_port->dll = baud_divisor & 0xff; - com_port->dlm = (baud_divisor >> 8) & 0xff; - com_port->lcr = LCRVAL; - com_port->mcr = MCRVAL; - com_port->fcr = FCRVAL; + com_port->ier = 0x00; + com_port->lcr = LCR_BKSE; + com_port->dll = baud_divisor & 0xff; + com_port->dlm = (baud_divisor >> 8) & 0xff; + com_port->lcr = LCRVAL; + com_port->mcr = MCRVAL; + com_port->fcr = FCRVAL; } -void -NS16550_putc(volatile struct NS16550 *com_port, char c) +void NS16550_putc (volatile struct NS16550 *com_port, char c) { - while ((com_port->lsr & LSR_THRE) == 0) ; - com_port->thr = c; + while ((com_port->lsr & LSR_THRE) == 0); + com_port->thr = c; } -char -NS16550_getc(volatile struct NS16550 *com_port) +char NS16550_getc (volatile struct NS16550 *com_port) { - while ((com_port->lsr & LSR_DR) == 0) ; - return (com_port->rbr); + while ((com_port->lsr & LSR_DR) == 0); + return (com_port->rbr); } -int -NS16550_tstc(volatile struct NS16550 *com_port) +int NS16550_tstc (volatile struct NS16550 *com_port) { - return ((com_port->lsr & LSR_DR) != 0); + return ((com_port->lsr & LSR_DR) != 0); } diff --git a/board/sandpoint/ns16550.h b/board/sandpoint/ns16550.h index a298cec..f525d74 100644 --- a/board/sandpoint/ns16550.h +++ b/board/sandpoint/ns16550.h @@ -10,16 +10,15 @@ */ -struct NS16550 -{ - char rbr; /* 0 */ - unsigned char ier; /* 1 */ - unsigned char fcr; /* 2 */ - unsigned char lcr; /* 3 */ - unsigned char mcr; /* 4 */ - unsigned char lsr; /* 5 */ - unsigned char msr; /* 6 */ - unsigned char scr; /* 7 */ +struct NS16550 { + char rbr; /* 0 */ + unsigned char ier; /* 1 */ + unsigned char fcr; /* 2 */ + unsigned char lcr; /* 3 */ + unsigned char mcr; /* 4 */ + unsigned char lsr; /* 5 */ + unsigned char msr; /* 6 */ + unsigned char scr; /* 7 */ }; #define thr rbr @@ -27,9 +26,9 @@ struct NS16550 #define dll rbr #define dlm ier -#define FCR_FIFO_EN 0x01 /*fifo enable*/ -#define FCR_RXSR 0x02 /*receiver soft reset*/ -#define FCR_TXSR 0x04 /*transmitter soft reset*/ +#define FCR_FIFO_EN 0x01 /*fifo enable */ +#define FCR_RXSR 0x02 /*receiver soft reset */ +#define FCR_TXSR 0x04 /*transmitter soft reset */ #define MCR_DTR 0x01 @@ -38,26 +37,26 @@ struct NS16550 #define MCR_TX_DFR 0x08 -#define LCR_WLS_MSK 0x03 /* character length slect mask*/ -#define LCR_WLS_5 0x00 /* 5 bit character length */ -#define LCR_WLS_6 0x01 /* 6 bit character length */ -#define LCR_WLS_7 0x02 /* 7 bit character length */ -#define LCR_WLS_8 0x03 /* 8 bit character length */ -#define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */ -#define LCR_PEN 0x08 /* Parity eneble*/ -#define LCR_EPS 0x10 /* Even Parity Select*/ -#define LCR_STKP 0x20 /* Stick Parity*/ -#define LCR_SBRK 0x40 /* Set Break*/ -#define LCR_BKSE 0x80 /* Bank select enable*/ +#define LCR_WLS_MSK 0x03 /* character length slect mask */ +#define LCR_WLS_5 0x00 /* 5 bit character length */ +#define LCR_WLS_6 0x01 /* 6 bit character length */ +#define LCR_WLS_7 0x02 /* 7 bit character length */ +#define LCR_WLS_8 0x03 /* 8 bit character length */ +#define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */ +#define LCR_PEN 0x08 /* Parity eneble */ +#define LCR_EPS 0x10 /* Even Parity Select */ +#define LCR_STKP 0x20 /* Stick Parity */ +#define LCR_SBRK 0x40 /* Set Break */ +#define LCR_BKSE 0x80 /* Bank select enable */ -#define LSR_DR 0x01 /* Data ready */ -#define LSR_OE 0x02 /* Overrun */ -#define LSR_PE 0x04 /* Parity error */ -#define LSR_FE 0x08 /* Framing error */ -#define LSR_BI 0x10 /* Break */ -#define LSR_THRE 0x20 /* Xmit holding register empty */ -#define LSR_TEMT 0x40 /* Xmitter empty */ -#define LSR_ERR 0x80 /* Error */ +#define LSR_DR 0x01 /* Data ready */ +#define LSR_OE 0x02 /* Overrun */ +#define LSR_PE 0x04 /* Parity error */ +#define LSR_FE 0x08 /* Framing error */ +#define LSR_BI 0x10 /* Break */ +#define LSR_THRE 0x20 /* Xmit holding register empty */ +#define LSR_TEMT 0x40 /* Xmitter empty */ +#define LSR_ERR 0x80 /* Error */ /* useful defaults for LCR*/ #define LCR_8N1 0x03 @@ -66,9 +65,8 @@ struct NS16550 #define COM1 0x03F8 #define COM2 0x02F8 -volatile struct NS16550 * NS16550_init(int chan, int baud_divisor); -void NS16550_putc(volatile struct NS16550 *com_port, char c); -char NS16550_getc(volatile struct NS16550 *com_port); -int NS16550_tstc(volatile struct NS16550 *com_port); -void NS16550_reinit(volatile struct NS16550 *com_port, int baud_divisor); - +volatile struct NS16550 *NS16550_init (int chan, int baud_divisor); +void NS16550_putc (volatile struct NS16550 *com_port, char c); +char NS16550_getc (volatile struct NS16550 *com_port); +int NS16550_tstc (volatile struct NS16550 *com_port); +void NS16550_reinit (volatile struct NS16550 *com_port, int baud_divisor); diff --git a/common/board.c b/common/board.c index 8c9c581..f9a6b0f 100644 --- a/common/board.c +++ b/common/board.c @@ -51,6 +51,8 @@ #endif #include +#undef DEBUG + static char *failed = "*** failed ***\n"; #ifdef CONFIG_PCU_E @@ -84,6 +86,11 @@ static ulong mem_malloc_start = 0; static ulong mem_malloc_end = 0; static ulong mem_malloc_brk = 0; +/************************************************************************ + * Utilities * + ************************************************************************ + */ + /* * The Malloc area is immediately below the monitor copy in DRAM */ @@ -127,25 +134,29 @@ strmhz(char *buf, long hz) return (buf); } -/* - * Breathe some life into the board... + +/************************************************************************ * - * Initialize an SMC for serial comms, and carry out some hardware - * tests. + * This is the first part of the initialization sequence that is + * implemented in C, but still running from ROM. + * + * The main purpose is to provide a (serial) console interface as + * soon as possible (so we can see any error messages), and to + * initialize the RAM so that we can relocate the monitor code to + * RAM. * - * The first part of initialization is running from Flash memory; - * its main purpose is to initialize the RAM so that we - * can relocate the monitor code to RAM. + * Be aware of the restrictions: global data is read-only, BSS is not + * initialized, and stack space is limited to a few kB. + * + ************************************************************************ */ + void board_init_f (ulong bootflag) { bd_t *bd; - ulong reg, len; - int board_type; - ulong addr_moni, addr_sp; - ulong dram_size; - int i, baudrate; + ulong reg, len, addr, addr_sp, dram_size; + int i, baudrate, board_type; char *s, *e; uchar tmp[64]; /* long enough for environment variables */ /* Pointer to initial global data area */ @@ -279,7 +290,11 @@ board_init_f (ulong bootflag) * Now that we have DRAM mapped and working, we can * relocate the code and continue running from DRAM. * - * First reserve memory for monitor code at end of DRAM. + * Reserve memory at end of RAM for (top down in that order): + * - protected RAM + * - LCD framebuffer + * - monitor code + * - board info struct */ len = get_endaddr() - CFG_MONITOR_BASE; @@ -292,45 +307,78 @@ board_init_f (ulong bootflag) if (CFG_MONITOR_LEN > len) len = CFG_MONITOR_LEN; -#ifdef CONFIG_PRAM /* reserve protected RAM at top of memory */ + addr = CFG_SDRAM_BASE + dram_size; + +#ifdef CONFIG_PRAM + /* + * reserve protected RAM + */ i = getenv_r ("pram", tmp, sizeof(tmp)); reg = (i > 0) ? simple_strtoul(tmp, NULL, 10) : CONFIG_PRAM; + addr -= (reg << 10); /* size is in kB */ # ifdef DEBUG - printf ("Reserving %ldk for protected RAM\n", reg); + printf ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); # endif - len += (reg << 10); /* size is in kB */ #endif /* CONFIG_PRAM */ - /* round up to next 4 kB limit */ - len = (len + (4096 - 1)) & ~(4096 - 1); + /* round down to next 4 kB limit */ + addr &= ~(4096 - 1); +#ifdef DEBUG + printf ("Top of RAM usable for PPCBoot at: %08lx\n", addr); +#endif + +#ifdef CONFIG_LCD + /* + * reserve memory for LCD display (always full pages) + */ + addr = lcd_setmem (addr); + idata->lcd_base = addr; +#endif /* CONFIG_LCD */ - addr_moni = CFG_SDRAM_BASE + dram_size - len; + /* + * reserve memory for PPCBoot code, data & bss + * round down to next 4 kB limit + */ + addr -= len; + addr &= ~(4096 - 1); #ifdef DEBUG - printf ("Relocating to: %08lx, %d bytes for malloc()\n", - addr_moni, TOTAL_MALLOC_LEN); + printf ("Reserving %ldk for PPCBoot at: %08lx\n", + len>>10, addr); #endif /* - * Then we (permanently) allocate a Board Info struct. - * - * We leave room for the malloc() arena. + * reserve memory for malloc() arena */ - len = sizeof(bd_t) + TOTAL_MALLOC_LEN; - - bd = (bd_t *)(addr_moni - len); + addr_sp = addr - TOTAL_MALLOC_LEN; +#ifdef DEBUG + printf ("Reserving %dk for malloc() at: %08lx\n", + TOTAL_MALLOC_LEN>>10, addr_sp); +#endif + /* + * (permanently) allocate a Board Info struct + */ + addr_sp -= sizeof(bd_t); + bd = (bd_t *)addr_sp; #ifdef DEBUG - printf ("Board Info at: %08lx\n", (ulong)bd); + printf ("Reserving %d Bytes for Board Info at: %08lx\n", + sizeof(bd_t), addr_sp); #endif /* * Finally, we set up a new (bigger) stack. * * Leave some safety gap for SP, force alignment on 16 byte boundary + * Clear initial stack frame */ - addr_sp = (ulong)bd - 128; + addr_sp -= 16; addr_sp &= ~0xF; + *((ulong *)addr_sp)-- = 0; + *((ulong *)addr_sp)-- = 0; +#ifdef DEBUG + printf ("Stack Pointer at: %08lx\n", addr_sp); +#endif /* * Save local variables to board info struct @@ -458,11 +506,22 @@ board_init_f (ulong bootflag) watchdog_reset (); #endif /* CONFIG_WATCHDOG */ - relocate_code (addr_sp, bd, addr_moni); + relocate_code (addr_sp, bd, addr); /* NOTREACHED - relocate_code() does not return */ } + +/************************************************************************ + * + * This is the next part if the initialization sequence: we are now + * running from RAM and have a "normal" C environment, i. e. global + * data can be written, BSS has been cleared, the stack size in not + * that critical any more, etc. + * + ************************************************************************ + */ + void board_init_r (bd_t *bd, ulong dest_addr) { char *s; @@ -475,7 +534,7 @@ void board_init_r (bd_t *bd, ulong dest_addr) extern void malloc_bin_reloc (ulong); #ifdef DEBUG - printf ("Now running in RAM - dest_addr = 0x%08lx\n", dest_addr); + printf ("Now running in RAM - PPCBoot at: %08lx\n", dest_addr); #endif #if defined(CONFIG_WATCHDOG) @@ -606,6 +665,14 @@ void board_init_r (bd_t *bd, ulong dest_addr) watchdog_reset (); #endif /* CONFIG_WATCHDOG */ +/** leave this here (after malloc() end environment are working) **/ + /* Initialize devices */ + devices_init (bd, reloc_off); + + /* Initialize the console (after the relocation and devices init) */ + console_init_r (reloc_off); +/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ + #if defined(CONFIG_COGENT) || \ defined(CONFIG_CPCI405) || \ defined(CONFIG_EVB64260) || \ @@ -660,7 +727,7 @@ void board_init_r (bd_t *bd, ulong dest_addr) #endif #ifdef DEBUG - printf ("Monitor relocated to 0x%08lx\n", dest_addr); + printf ("PPCBoot relocated to %08lx\n", dest_addr); #endif /* @@ -728,15 +795,6 @@ void board_init_r (bd_t *bd, ulong dest_addr) bedbug_init(); #endif -/** LEAVE THIS HERE **/ - /* Initialize devices */ - devices_init (reloc_off); - - /* Initialize the console (after the relocation and devices init) */ - console_init_r (reloc_off); - putc('\n'); -/**********************/ - #ifdef CONFIG_PRAM /* * Export available size of memory for Linux, diff --git a/common/console.c b/common/console.c index ec96619..e6b9124 100644 --- a/common/console.c +++ b/common/console.c @@ -33,206 +33,214 @@ * environment are used */ #ifdef CFG_CONSOLE_OVERWRITE_ROUTINE -extern int overwrite_console(void); +extern int overwrite_console (void); #else -int overwrite_console(void) +int overwrite_console (void) { return (0); } -#endif +#endif /* CFG_CONSOLE_OVERWRITE_ROUTINE */ #endif /* CFG_CONSOLE_IS_IN_ENV */ -static int console_setfile(int file, device_t *dev) +static int console_setfile (int file, device_t * dev) { - int error = 0; - - if (dev == NULL) - return -1 ; - - switch (file) - { - case stdin: - case stdout: - case stderr: - /* Start new device */ - if (dev->start) - { - error = dev->start() ; - /* If it's not started dont use it */ - if (error < 0) - break; - } - - /* Assign the new device (leaving the existing one started) */ - stdio_devices[file] = dev ; + int error = 0; + + if (dev == NULL) + return -1; + + switch (file) { + case stdin: + case stdout: + case stderr: + /* Start new device */ + if (dev->start) { + error = dev->start (); + /* If it's not started dont use it */ + if (error < 0) + break; + } - /* Update monitor functions (to use the console stuff by other applications) */ - switch (file){ - case stdin: - bd_ptr->bi_mon_fnc->getc = dev->getc ; - bd_ptr->bi_mon_fnc->tstc = dev->tstc ; - break; - case stdout: - bd_ptr->bi_mon_fnc->putc = dev->putc ; - bd_ptr->bi_mon_fnc->puts = dev->puts ; - bd_ptr->bi_mon_fnc->printf = printf ; + /* Assign the new device (leaving the existing one started) */ + stdio_devices[file] = dev; + + /* + * Update monitor functions + * (to use the console stuff by other applications) + */ + switch (file) { + case stdin: + bd_ptr->bi_mon_fnc->getc = dev->getc; + bd_ptr->bi_mon_fnc->tstc = dev->tstc; + break; + case stdout: + bd_ptr->bi_mon_fnc->putc = dev->putc; + bd_ptr->bi_mon_fnc->puts = dev->puts; + bd_ptr->bi_mon_fnc->printf = printf; + break; + } break; - } - break; - default: /* Invalid file ID */ - error = -1 ; - } - return error ; + default: /* Invalid file ID */ + error = -1; + } + return error; } /** PPCBOOT INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/ -void serial_printf(const char *fmt, ...) +void serial_printf (const char *fmt, ...) { - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; + va_list args; + uint i; + char printbuffer[CFG_PBSIZE]; - va_start(args, fmt); + va_start (args, fmt); /* For this to work, printbuffer must be larger than * anything we ever want to print. */ - i = vsprintf(printbuffer, fmt, args); - va_end(args); + i = vsprintf (printbuffer, fmt, args); + va_end (args); - serial_puts(printbuffer); + serial_puts (printbuffer); } -int fgetc(int file) +int fgetc (int file) { - if (file < MAX_FILES) - return stdio_devices[file]->getc(); + if (file < MAX_FILES) + return stdio_devices[file]->getc (); - return -1 ; + return -1; } -int ftstc(int file) +int ftstc (int file) { - if (file < MAX_FILES) - return stdio_devices[file]->tstc(); + if (file < MAX_FILES) + return stdio_devices[file]->tstc (); - return -1 ; + return -1; } -void fputc(int file, const char c) +void fputc (int file, const char c) { - if (file < MAX_FILES) - stdio_devices[file]->putc(c); + if (file < MAX_FILES) + stdio_devices[file]->putc (c); } -void fputs(int file, const char *s) +void fputs (int file, const char *s) { - if (file < MAX_FILES) - stdio_devices[file]->puts(s); + if (file < MAX_FILES) + stdio_devices[file]->puts (s); } -void fprintf(int file, const char *fmt, ...) +void fprintf (int file, const char *fmt, ...) { - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; + va_list args; + uint i; + char printbuffer[CFG_PBSIZE]; - va_start(args, fmt); + va_start (args, fmt); /* For this to work, printbuffer must be larger than * anything we ever want to print. */ - i = vsprintf(printbuffer, fmt, args); - va_end(args); + i = vsprintf (printbuffer, fmt, args); + va_end (args); /* Send to desired file */ - fputs(file, printbuffer); + fputs (file, printbuffer); } /** PPCBOOT INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/ -int getc(void) +int getc (void) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - if (idata->relocated) - /* Get from the standard input */ - return fgetc (stdin); + if (idata->relocated) { + /* Get from the standard input */ + return fgetc (stdin); + } - /* Send directly to the handler */ - return serial_getc(); + /* Send directly to the handler */ + return serial_getc (); } -int tstc(void) +int tstc (void) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - if (idata->relocated) - /* Test the standard input */ - return ftstc (stdin); + if (idata->relocated) { + /* Test the standard input */ + return ftstc (stdin); + } - /* Send directly to the handler */ - return serial_tstc(); + /* Send directly to the handler */ + return serial_tstc (); } -void putc(const char c) +void putc (const char c) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - - if (idata->relocated) - /* Send to the standard output */ - fputc (stdout, c); - else - /* Send directly to the handler */ - serial_putc(c); + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + + if (idata->relocated) { + /* Send to the standard output */ + fputc (stdout, c); + } else { + /* Send directly to the handler */ + serial_putc (c); + } } -void puts(const char *s) +void puts (const char *s) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - - if (idata->relocated) - /* Send to the standard output */ - fputs (stdout, s); - else - /* Send directly to the handler */ - serial_puts(s); + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + + if (idata->relocated) { + /* Send to the standard output */ + fputs (stdout, s); + } else { + /* Send directly to the handler */ + serial_puts (s); + } } -void printf(const char *fmt, ...) +void printf (const char *fmt, ...) { - va_list args; - uint i; - char printbuffer[CFG_PBSIZE]; + va_list args; + uint i; + char printbuffer[CFG_PBSIZE]; - va_start(args, fmt); + va_start (args, fmt); /* For this to work, printbuffer must be larger than * anything we ever want to print. */ - i = vsprintf(printbuffer, fmt, args); - va_end(args); + i = vsprintf (printbuffer, fmt, args); + va_end (args); /* Print the string */ puts (printbuffer); } /* test if ctrl-c was pressed */ -static int ctrlc_disabled = 0; /* see disable_ctrl() */ +static int ctrlc_disabled = 0; /* see disable_ctrl() */ static int ctrlc_was_pressed = 0; -int -ctrlc(void) +int ctrlc (void) { init_data_t *idata = - (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); if (!ctrlc_disabled && idata->have_console) { - if (tstc()) { - switch (getc()) { - case 0x03: /* ^C - Control C */ + if (tstc ()) { + switch (getc ()) { + case 0x03: /* ^C - Control C */ ctrlc_was_pressed = 1; return 1; default: @@ -246,22 +254,20 @@ ctrlc(void) /* pass 1 to disable ctrlc() checking, 0 to enable. * returns previous state */ -int -disable_ctrlc(int disable) +int disable_ctrlc (int disable) { int prev = ctrlc_disabled; /* save previous state */ + ctrlc_disabled = disable; return prev; } -int -had_ctrlc(void) +int had_ctrlc (void) { return ctrlc_was_pressed; } -void -clear_ctrlc(void) +void clear_ctrlc (void) { ctrlc_was_pressed = 0; } @@ -270,204 +276,225 @@ clear_ctrlc(void) int console_assign (int file, char *devname) { - int flag , i; - - /* Check for valid file */ - switch(file){ - case stdin: - flag = DEV_FLAGS_INPUT ; - break; - case stdout: - case stderr: - flag = DEV_FLAGS_OUTPUT ; - break; - default: - return -1 ; - } - - /* Check for valid device name */ - - for(i=1; i<=ListNumItems(devlist); i++) - { - device_t *dev = ListGetPtrToItem (devlist,i) ; - - if (strcmp (devname, dev->name) == 0) - { - if (dev->flags & flag) - return console_setfile(file, dev) ; - - return -1 ; + int flag, i; + + /* Check for valid file */ + switch (file) { + case stdin: + flag = DEV_FLAGS_INPUT; + break; + case stdout: + case stderr: + flag = DEV_FLAGS_OUTPUT; + break; + default: + return -1; + } + + /* Check for valid device name */ + + for (i = 1; i <= ListNumItems (devlist); i++) { + device_t *dev = ListGetPtrToItem (devlist, i); + + if (strcmp (devname, dev->name) == 0) { + if (dev->flags & flag) + return console_setfile (file, dev); + + return -1; + } } - } - return -1 ; + return -1; } /* Called before relocation - use serial functions */ -void console_init_f (void) +void console_init_f (void) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - - idata->relocated = 0 ; /* Use these pointers before relocation */ - idata->bi_mon_fnc.getc = serial_getc; - idata->bi_mon_fnc.tstc = serial_tstc; - idata->bi_mon_fnc.putc = serial_putc; - idata->bi_mon_fnc.puts = serial_puts; - idata->bi_mon_fnc.printf = serial_printf; + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + + idata->relocated = 0; /* Use these pointers before relocation */ + idata->bi_mon_fnc.getc = serial_getc; + idata->bi_mon_fnc.tstc = serial_tstc; + idata->bi_mon_fnc.putc = serial_putc; + idata->bi_mon_fnc.puts = serial_puts; + idata->bi_mon_fnc.printf = serial_printf; } #ifdef CFG_CONSOLE_IS_IN_ENV /* search a device */ -device_t *search_device(int flags, char * name) +device_t *search_device (int flags, char *name) { - int i,items; - device_t *dev = NULL; - items = ListNumItems(devlist); - if(name==NULL) + int i, items; + device_t *dev = NULL; + + items = ListNumItems (devlist); + if (name == NULL) return dev; - for (i=1; i<=items; i++) { - dev = ListGetPtrToItem(devlist, i) ; - if ((dev->flags & flags) && (strcmp(name,dev->name)==0)) { + + for (i = 1; i <= items; i++) { + dev = ListGetPtrToItem (devlist, i); + if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) { break; } } return dev; } -#endif /* CFG_CONSOLE_IS_IN_ENV */ +#endif /* CFG_CONSOLE_IS_IN_ENV */ -#ifdef CFG_CONSOLE_IS_IN_ENV +#ifdef CFG_CONSOLE_IS_IN_ENV /* Called after the relocation - use desired console functions */ -void console_init_r (ulong reloc_offset) +void console_init_r (ulong reloc_offset) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL; + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL; + /* sdtin stdout and stderr are in environment */ /* scan for it */ - char *stdinname = getenv("stdin"); - char *stdoutname = getenv("stdout"); - char *stderrname = getenv("stderr"); + char *stdinname = getenv ("stdin"); + char *stdoutname = getenv ("stdout"); + char *stderrname = getenv ("stderr"); /* Global pointer to monitor structure (updated by the console stuff) */ - bd_ptr->bi_mon_fnc = &idata->bi_mon_fnc ; - - if(overwrite_console()==0) { /* if not overwritten by config switch */ - inputdev=search_device(DEV_FLAGS_INPUT,stdinname); - outputdev=search_device(DEV_FLAGS_OUTPUT,stdoutname); - errdev=search_device(DEV_FLAGS_OUTPUT,stderrname); + bd_ptr->bi_mon_fnc = &idata->bi_mon_fnc; + + if (overwrite_console () == 0) { /* if not overwritten by config switch */ + inputdev = search_device (DEV_FLAGS_INPUT, stdinname); + outputdev = search_device (DEV_FLAGS_OUTPUT, stdoutname); + errdev = search_device (DEV_FLAGS_OUTPUT, stderrname); } /* if the devices are overwritten or not found, use default device */ - if(inputdev==NULL) - inputdev=search_device(DEV_FLAGS_INPUT,"serial"); - if(outputdev==NULL) - outputdev=search_device(DEV_FLAGS_OUTPUT,"serial"); - if(errdev==NULL) - errdev=search_device(DEV_FLAGS_OUTPUT,"serial"); - /* Initializes output console first */ - if (outputdev != NULL) - console_setfile(stdout, outputdev); - if (errdev != NULL) - console_setfile(stderr, errdev); - if (inputdev != NULL) - console_setfile(stdin, inputdev); - - /* Print informations */ - printf("In: "); - if (stdio_devices[stdin] == NULL) - printf("No input devices available!\n"); - else - printf("%s\n", stdio_devices[stdin]->name); - - printf("Out: "); - if (stdio_devices[stdout] == NULL) - printf("No output devices available!\n"); - else - printf("%s\n", stdio_devices[stdout]->name); - - printf("Err: "); - if (stdio_devices[stderr] == NULL) - printf("No error devices available!\n"); - else - printf("%s\n", stdio_devices[stderr]->name); + if (inputdev == NULL) { + inputdev = search_device (DEV_FLAGS_INPUT, "serial"); + } + if (outputdev == NULL) { + outputdev = search_device (DEV_FLAGS_OUTPUT, "serial"); + } + if (errdev == NULL) { + errdev = search_device (DEV_FLAGS_OUTPUT, "serial"); + } + /* Initializes output console first */ + if (outputdev != NULL) { + console_setfile (stdout, outputdev); + } + if (errdev != NULL) { + console_setfile (stderr, errdev); + } + if (inputdev != NULL) { + console_setfile (stdin, inputdev); + } + + /* Print information */ + printf ("In: "); + if (stdio_devices[stdin] == NULL) { + printf ("No input devices available!\n"); + } else { + printf ("%s\n", stdio_devices[stdin]->name); + } + + printf ("Out: "); + if (stdio_devices[stdout] == NULL) { + printf ("No output devices available!\n"); + } else { + printf ("%s\n", stdio_devices[stdout]->name); + } + + printf ("Err: "); + if (stdio_devices[stderr] == NULL) { + printf ("No error devices available!\n"); + } else { + printf ("%s\n", stdio_devices[stderr]->name); + } #ifdef CFG_CONSOLE_ENV_OVERWRITE - /* set the environment variables (will overwrite previous env settings) */ - for (i=0; i<3; i++) - setenv(stdio_names[i], stdio_devices[i]->name); + /* set the environment variables (will overwrite previous env settings) */ + for (i = 0; i < 3; i++) { + setenv (stdio_names[i], stdio_devices[i]->name); + } #endif /* CFG_CONSOLE_ENV_OVERWRITE */ + /* If nothing usable installed, use only the initial console */ if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) - return ; + return; /* Set the relocation flag */ idata->relocated = reloc_offset; } - #else /* CFG_CONSOLE_IS_IN_ENV */ -/* Called after the relocation - use desierd console functions */ -void console_init_r (ulong reloc_offset) + +/* Called after the relocation - use desired console functions */ +void console_init_r (ulong reloc_offset) { - init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); - device_t *inputdev = NULL, *outputdev = NULL ; - int i, items = ListNumItems(devlist) ; - + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); + device_t *inputdev = NULL, *outputdev = NULL; + int i, items = ListNumItems (devlist); + /* Global pointer to monitor structure (updated by the console stuff) */ - bd_ptr->bi_mon_fnc = &idata->bi_mon_fnc ; - - - /* Scan devices looking for input and output devices */ - for (i=1; (i<=items) && ((inputdev == NULL) || (outputdev == NULL)); i++) - { - device_t *dev = ListGetPtrToItem(devlist, i) ; - - if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev==NULL)) - inputdev = dev ; - - if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev==NULL)) - outputdev = dev ; - } - - /* Initializes output console first */ - if (outputdev != NULL) - { - console_setfile(stdout, outputdev); - console_setfile(stderr, outputdev); - } - - /* Initializes input console */ - if (inputdev != NULL) - console_setfile(stdin, inputdev); - - /* Print informations */ - printf("In: "); - if (stdio_devices[stdin] == NULL) - printf("No input devices available!\n"); - else - printf("%s\n", stdio_devices[stdin]->name); - - printf("Out: "); - if (stdio_devices[stdout] == NULL) - printf("No output devices available!\n"); - else - printf("%s\n", stdio_devices[stdout]->name); - - printf("Err: "); - if (stdio_devices[stderr] == NULL) - printf("No error devices available!\n"); - else - printf("%s\n", stdio_devices[stderr]->name); - - /* Setting environment variables */ - for (i=0; i<3; i++) - setenv(stdio_names[i], stdio_devices[i]->name); - - /* If nothing usable installed, use only the initial console */ - if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) - return ; - - /* Set the relocation flag */ - idata->relocated = reloc_offset; + bd_ptr->bi_mon_fnc = &idata->bi_mon_fnc; + + + /* Scan devices looking for input and output devices */ + for (i = 1; + (i <= items) && ((inputdev == NULL) || (outputdev == NULL)); + i++ + ) { + device_t *dev = ListGetPtrToItem (devlist, i); + + if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) { + inputdev = dev; + } + if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev == NULL)) { + outputdev = dev; + } + } + + /* Initializes output console first */ + if (outputdev != NULL) { + console_setfile (stdout, outputdev); + console_setfile (stderr, outputdev); + } + + /* Initializes input console */ + if (inputdev != NULL) { + console_setfile (stdin, inputdev); + } + + /* Print informations */ + printf ("In: "); + if (stdio_devices[stdin] == NULL) { + printf ("No input devices available!\n"); + } else { + printf ("%s\n", stdio_devices[stdin]->name); + } + + printf ("Out: "); + if (stdio_devices[stdout] == NULL) { + printf ("No output devices available!\n"); + } else { + printf ("%s\n", stdio_devices[stdout]->name); + } + + printf ("Err: "); + if (stdio_devices[stderr] == NULL) { + printf ("No error devices available!\n"); + } else { + printf ("%s\n", stdio_devices[stderr]->name); + } + + /* Setting environment variables */ + for (i = 0; i < 3; i++) { + setenv (stdio_names[i], stdio_devices[i]->name); + } + + /* If nothing usable installed, use only the initial console */ + if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) + return; + + /* Set the relocation flag */ + idata->relocated = reloc_offset; } #endif /* CFG_CONSOLE_IS_IN_ENV */ - diff --git a/common/devices.c b/common/devices.c index 6d7fe33..0a4a2e8 100644 --- a/common/devices.c +++ b/common/devices.c @@ -27,98 +27,94 @@ #include #include -list_t devlist = 0 ; -device_t *stdio_devices[] = {NULL,NULL,NULL} ; -char *stdio_names[MAX_FILES] = {"stdin", "stdout", "stderr"} ; +list_t devlist = 0; +device_t *stdio_devices[] = { NULL, NULL, NULL }; +char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" }; -#ifdef CONFIG_VIDEO -extern int drv_video_init(void); -#endif -#ifdef CONFIG_WL_4PPM_KEYBOARD -extern int drv_wlkbd_init(void); -#endif -#ifdef CONFIG_ISA_KEYBOARD -extern int drv_isa_kbd_init(void); -#endif -// ************************************************************************** -// * SYSTEM DRIVERS -// ************************************************************************** +/************************************************************************** + * SYSTEM DRIVERS + ************************************************************************** + */ static int drv_system_init (void) { - int error, devices = 1 ; - device_t serdev ; + int error, devices = 1; + device_t serdev; - memset (&serdev, 0, sizeof(serdev)); + memset (&serdev, 0, sizeof (serdev)); - strcpy(serdev.name, "serial"); - serdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; + strcpy (serdev.name, "serial"); + serdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; #if CONFIG_SERIAL_SOFTWARE_FIFO - serial_buffered_init(); - serdev.putc = serial_buffered_putc ; - serdev.puts = serial_buffered_puts ; - serdev.getc = serial_buffered_getc ; - serdev.tstc = serial_buffered_tstc ; + serial_buffered_init (); + serdev.putc = serial_buffered_putc; + serdev.puts = serial_buffered_puts; + serdev.getc = serial_buffered_getc; + serdev.tstc = serial_buffered_tstc; #else - serdev.putc = serial_putc ; - serdev.puts = serial_puts ; - serdev.getc = serial_getc ; - serdev.tstc = serial_tstc ; + serdev.putc = serial_putc; + serdev.puts = serial_puts; + serdev.getc = serial_getc; + serdev.tstc = serial_tstc; #endif - error = device_register (&serdev); + error = device_register (&serdev); - return (error == 0) ? devices : error ; + return (error == 0) ? devices : error; } -// ************************************************************************** -// * DEVICES -// ************************************************************************** +/************************************************************************** + * DEVICES + ************************************************************************** + */ -int device_register (device_t *dev) +int device_register (device_t * dev) { - ListInsertItem (devlist, dev, LIST_END); - return 0 ; + ListInsertItem (devlist, dev, LIST_END); + return 0; } -int devices_init (ulong relocation_offset) +int devices_init (bd_t *bd, ulong relocation_offset) { - int i; + int i; - /* relocate device name pointers */ - for (i=0; i<(sizeof(stdio_names)/sizeof(char *)); ++i) { - stdio_names[i] = (char *)(((ulong)stdio_names[i]) + relocation_offset); - } + /* relocate device name pointers */ + for (i = 0; i < (sizeof (stdio_names) / sizeof (char *)); ++i) { + stdio_names[i] = (char *) (((ulong) stdio_names[i]) + + relocation_offset); + } - /* Initialize the list */ - devlist = ListCreate(sizeof(device_t)) ; + /* Initialize the list */ + devlist = ListCreate (sizeof (device_t)); - if (devlist == NULL) { - eputs("Cannot initialize the list of devices!\n"); - return -1 ; - } + if (devlist == NULL) { + eputs ("Cannot initialize the list of devices!\n"); + return -1; + } #if defined(CONFIG_I2C) && !defined(CONFIG_8xx) && !defined(CONFIG_8260) - i2c_init(); + i2c_init (); +#endif +#ifdef CONFIG_LCD + drv_lcd_init (bd); #endif #ifdef CONFIG_VIDEO - drv_video_init(); + drv_video_init (); #endif #ifdef CONFIG_WL_4PPM_KEYBOARD - drv_wlkbd_init(); + drv_wlkbd_init (); #endif #ifdef CONFIG_ISA_KEYBOARD - drv_isa_kbd_init(); + drv_isa_kbd_init (); #endif - drv_system_init(); + drv_system_init (); - return ListNumItems(devlist) ; + return ListNumItems (devlist); } int devices_done (void) { - ListDispose(devlist); + ListDispose (devlist); - return 0 ; + return 0; } - diff --git a/common/hush.c b/common/hush.c index 4a3ac86..d494ade 100644 --- a/common/hush.c +++ b/common/hush.c @@ -361,7 +361,7 @@ static inline void debug_printf(const char *format, ...) { } #define final_printf debug_printf #ifdef __PPCBOOT__ static void syntax_err(void) { - printf("syntax error\n"); + printf("syntax error\n"); } #else static void __syntax(char *file, int line) { @@ -457,8 +457,8 @@ static int parse_string_outer(const char *s); static int parse_file_outer(FILE *f); #else static int parse_stream_outer(struct in_str *inp, int end); -int parse_string_outer(char *s); int ppcboot_hush_start(bd_t *bd); +int parse_string_outer(char *s); static int parse_file_outer(void); #endif #ifndef __PPCBOOT__ @@ -873,13 +873,11 @@ static void b_free(o_string *o) */ static int b_addqchr(o_string *o, int ch, int quote) { -#ifndef __PPCBOOT__ if (quote && strchr("*?[\\",ch)) { int rc; rc = b_addchr(o, '\\'); if (rc) return rc; } -#endif /* __PPCBOOT__ */ return b_addchr(o, ch); } @@ -980,9 +978,12 @@ static void get_user_input(struct in_str *i) static char the_command[CFG_CBSIZE]; if (i->promptmode == 1) { - readline(CFG_PROMPT); + n = readline(CFG_PROMPT); } else { - readline(CFG_PROMPT_HUSH_PS2); + n = readline(CFG_PROMPT_HUSH_PS2); + } + if (n == -1 ) { + i->__promptme = 0; } n = strlen(console_buffer); console_buffer[n] = '\n'; @@ -991,7 +992,7 @@ static void get_user_input(struct in_str *i) if (console_buffer[0] == '\n'&& flag_repeat == 0) { i->p = console_buffer; } - else { + else { if (console_buffer[0] != '\n') { strcpy(the_command,console_buffer); flag_repeat = 1; @@ -1015,6 +1016,10 @@ static void get_user_input(struct in_str *i) the_command[1] = '\0'; } } + if (i->__promptme == 0) { + the_command[0] = '\n'; + the_command[1] = '\0'; + } i->p = console_buffer; } #endif @@ -1035,14 +1040,16 @@ static int file_get(struct in_str *i) * more complicated by now, like sourcing or substituting. */ #ifndef __PPCBOOT__ if (i->__promptme && interactive && i->file == stdin) { - while(! i->p || (interactive && strlen(i->p)==0) ) { + while(! i->p || (interactive && strlen(i->p)==0) ) { #else - while(! i->p || strlen(i->p)==0 ) { + while(! i->p || strlen(i->p)==0 ) { #endif get_user_input(i); } i->promptmode=2; +#ifndef __PPCBOOT__ i->__promptme = 0; +#endif if (i->p && *i->p) { ch=*i->p++; } @@ -1053,7 +1060,9 @@ static int file_get(struct in_str *i) #endif debug_printf("b_getch: got a %d\n", ch); } +#ifndef __PPCBOOT__ if (ch == '\n') i->__promptme=1; +#endif return ch; } @@ -1465,7 +1474,7 @@ static int run_pipe_real(struct pipe *pi) struct built_in_command *x; #else int nextin; - int flag = 0; + int flag = 0; struct child_prog *child; cmd_tbl_t *cmdtp; #endif @@ -1490,7 +1499,7 @@ static int run_pipe_real(struct pipe *pi) rcode = run_list_real(child->group); restore_redirects(squirrel); #else - if (pi->num_progs == 1 && child->group) { + if (pi->num_progs == 1 && child->group) { int rcode; debug_printf("non-subshell grouping\n"); rcode = run_list_real(child->group); @@ -1514,9 +1523,11 @@ static int run_pipe_real(struct pipe *pi) value = strchr(name, '='); if (value) *value=0; +#ifndef __PPCBOOT__ if ( get_local_var(name)) { export_me=1; } +#endif free(name); set_local_var(child->argv[i], export_me); } @@ -1540,7 +1551,7 @@ static int run_pipe_real(struct pipe *pi) * things seem to work with glibc. */ setup_redirects(child, squirrel); #else - /* Look up command in command table */ + /* Look up command in command table */ if ((cmdtp = find_cmd(child->argv[i])) == NULL) { printf ("Unknown command '%s' - try 'help'\n", child->argv[i]); return 1; /* give up after bad command */ @@ -1756,13 +1767,13 @@ static int free_pipe(struct pipe *pi, int indent) for (a = child->argc;a >= 0;a--) { free(child->argv[a]); } - free(child->argv); + free(child->argv); child->argc = 0; #endif child->argv=NULL; } else if (child->group) { #ifndef __PPCBOOT__ - final_printf("%s begin group (subshell:%d)\n",ind, child->subshell); + final_printf("%s begin group (subshell:%d)\n",ind, child->subshell); #endif ret_code = free_pipe_list(child->group,indent+3); final_printf("%s end group\n",ind); @@ -1947,7 +1958,13 @@ static int set_local_var(const char *s, int flg_export) struct variables *cur; name=strdup(s); - +#ifdef __PPCBOOT__ + if (getenv(name) != NULL) { + printf ("ERROR: " + "There is a global environmet variable with the same name.\n"); + return -1; + } +#endif /* Assume when we enter this function that we are already in * NAME=VALUE format. So the first order of business is to * split 's' on the '=' into 'name' and 'value' */ @@ -2123,7 +2140,7 @@ static void initialize_context(struct p_context *ctx) ctx->w=RES_NONE; ctx->stack=NULL; #ifdef __PPCBOOT__ - ctx->old_flag=0; + ctx->old_flag=0; #endif done_command(ctx); /* creates the memory for working child */ } @@ -2206,8 +2223,8 @@ static int done_word(o_string *dest, struct p_context *ctx) glob_t *glob_target; int gr, flags = 0; #else - char *str; - int argc; + char *str, *s; + int argc, cnt; #endif debug_printf("done_word: %s %p\n", dest->data, child); @@ -2232,7 +2249,11 @@ static int done_word(o_string *dest, struct p_context *ctx) glob_target = &child->glob_result; if (child->argv) flags |= GLOB_APPEND; #else - str = malloc((strlen(dest->data) + 1)); + for (cnt = 1, s = dest->data; s && *s; s++) { + if (*s == '\\') s++; + cnt++; + } + str = malloc(cnt); if (!str) return 1; if ( child->argv == NULL) { child->argc=0; @@ -2242,7 +2263,11 @@ static int done_word(o_string *dest, struct p_context *ctx) if (child->argv == NULL) return 1; child->argv[argc-1]=str; child->argv[argc]=NULL; - strcpy(str,dest->data); + for (s = dest->data; s && *s; s++,str++) { + if (*s == '\\') s++; + *str = *s; + } + *str = '\0'; #endif #ifndef __PPCBOOT__ } @@ -2281,7 +2306,7 @@ static int done_command(struct p_context *ctx) #ifndef __PPCBOOT__ && prog->redirects == NULL) { #else - ) { + ) { #endif debug_printf("done_command: skipping null command\n"); return 0; @@ -2490,15 +2515,12 @@ static int parse_group(o_string *dest, struct p_context *ctx, static void lookup_param(o_string *dest, struct p_context *ctx, o_string *src) { const char *p=NULL; -#ifndef __PPCBOOT__ + if (src->data) { p = getenv(src->data); if (!p) -#endif - p = get_local_var(src->data); -#ifndef __PPCBOOT__ + p = get_local_var(src->data); } -#endif if (p) parse_string(dest, ctx, p); /* recursion */ b_free(src); } @@ -2509,7 +2531,7 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i #ifndef __PPCBOOT__ int i, advance=0; #else - int advance=0; + int advance=0; #endif o_string alt=NULL_O_STRING; #ifndef __PPCBOOT__ @@ -2621,6 +2643,9 @@ int parse_stream(o_string *dest, struct p_context *ctx, debug_printf("parse_stream, end_trigger=%d\n",end_trigger); while ((ch=b_getch(input))!=EOF) { m = map[ch]; +#ifdef __PPCBOOT__ + if (input->__promptme == 0) return 1; +#endif next = (ch == '\n') ? 0 : b_peek(input); debug_printf("parse_stream: ch=%c (%d) m=%d quote=%d\n", ch,ch,m,dest->quote); @@ -2660,7 +2685,6 @@ int parse_stream(o_string *dest, struct p_context *ctx, b_addqchr(dest, ch, dest->quote); } break; -#ifndef __PPCBOOT__ case '\\': if (next == EOF) { syntax(); @@ -2669,14 +2693,15 @@ int parse_stream(o_string *dest, struct p_context *ctx, b_addqchr(dest, '\\', dest->quote); b_addqchr(dest, b_getch(input), dest->quote); break; -#endif case '$': if (handle_dollar(dest, ctx, input)!=0) return 1; break; -#ifndef __PPCBOOT__ case '\'': dest->nonnull = 1; while(ch=b_getch(input),ch!=EOF && ch!='\'') { +#ifdef __PPCBOOT__ + if(input->__promptme == 0) return 1; +#endif b_addchr(dest,ch); } if (ch==EOF) { @@ -2684,7 +2709,6 @@ int parse_stream(o_string *dest, struct p_context *ctx, return 1; } break; -#endif case '"': dest->nonnull = 1; dest->quote = !dest->quote; @@ -2736,9 +2760,8 @@ int parse_stream(o_string *dest, struct p_context *ctx, #ifndef __PPCBOOT__ done_pipe(ctx,PIPE_BG); #else - syntax_err(); + syntax_err(); return 1; - #endif } break; @@ -2754,7 +2777,7 @@ int parse_stream(o_string *dest, struct p_context *ctx, #ifndef __PPCBOOT__ done_command(ctx); #else - syntax_err(); + syntax_err(); return 1; #endif } @@ -2811,7 +2834,7 @@ void update_ifs_map(void) mapset("\\$'\"`", 3); /* never flow through */ mapset("<>;&|(){}#", 1); /* flow through if quoted */ #else - mapset("$'\"", 3); /* never flow through */ + mapset("\\$'\"", 3); /* never flow through */ mapset(";&|#", 1); /* flow through if quoted */ #endif mapset(ifs, 2); /* also flow through if quoted */ @@ -2847,15 +2870,19 @@ int parse_stream_outer(struct in_str *inp, int end) if (ctx.old_flag != 0) { free(ctx.stack); b_reset(&temp); - } + } + if (inp->__promptme == 0) printf("\n"); + inp->__promptme = 1; + temp.nonnull = 0; + temp.quote = 0; inp->p = NULL; free_pipe_list(ctx.list_head,0); b_free(&temp); } - } while (end != 1); + } while (end != 1); return (rcode != 1) ? 0 : 1; #else - } while (rcode != -1); /* loop on syntax errors, return on EOF */ + } while (rcode != -1); /* loop on syntax errors, return on EOF */ return 0; #endif /* __PPCBOOT__ */ } @@ -2871,7 +2898,7 @@ int parse_string_outer(char *s) #ifdef __PPCBOOT__ if ( !s || !*s) return 1; - return parse_stream_outer(&input, 1); + return parse_stream_outer(&input, 1); #else return parse_stream_outer(&input); #endif /* __PPCBOOT__ */ @@ -2889,7 +2916,7 @@ static int parse_file_outer(void) setup_file_in_str(&input, f); rcode = parse_stream_outer(&input); #else - setup_file_in_str(&input); + setup_file_in_str(&input); rcode = parse_stream_outer(&input, 0); #endif /* __PPCBOOT__ */ return rcode; @@ -2898,17 +2925,17 @@ static int parse_file_outer(void) #ifdef __PPCBOOT__ int ppcboot_hush_start(bd_t *bd) { - extern bd_t *BD; + extern bd_t *BD; - BD = bd; + BD = bd; top_vars = malloc(sizeof(struct variables)); top_vars->name = "HUSH_VERSION"; top_vars->value = "0.01"; top_vars->next = 0; top_vars->flg_export = 0; top_vars->flg_read_only = 1; - parse_file_outer(); - return 1; + parse_file_outer(); + return 1; } #endif /* __PPCBOOT__ */ diff --git a/cpu/mpc8240/cpu_init.c b/cpu/mpc8240/cpu_init.c index 0120775..ac6d6fc 100644 --- a/cpu/mpc8240/cpu_init.c +++ b/cpu/mpc8240/cpu_init.c @@ -12,7 +12,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -34,119 +34,120 @@ void cpu_init_f (void) { -/* MOUSSE and SANDPOINT boards initialized in asm */ +/* MOUSSE and SANDPOINT boards initialized in asm */ #if !defined(CONFIG_MOUSSE) && !defined(CONFIG_SANDPOINT) register unsigned long val; CONFIG_WRITE_HALFWORD(PCICR, 0x06); /* Bus Master, respond to PCI memory space acesses*/ -/* CONFIG_WRITE_HALFWORD(PCISR, 0xffff); *//*reset PCISR*/ +/* CONFIG_WRITE_HALFWORD(PCISR, 0xffff); */ /*reset PCISR*/ CONFIG_READ_WORD(PICR1, val); CONFIG_WRITE_WORD( PICR1, (val & (PICR1_ADDRESS_MAP | PICR1_RCS0)) | - PIRC1_MSK | PICR1_PROC_TYPE_603E | - PICR1_FLASH_WR_EN | PICR1_MCP_EN | - PICR1_CF_DPARK | PICR1_EN_PCS | - PICR1_CF_APARK ); + PIRC1_MSK | PICR1_PROC_TYPE_603E | + PICR1_FLASH_WR_EN | PICR1_MCP_EN | + PICR1_CF_DPARK | PICR1_EN_PCS | + PICR1_CF_APARK ); CONFIG_READ_WORD(PICR2, val); val= val & ~ (PICR2_CF_SNOOP_WS_MASK | PICR2_CF_APHASE_WS_MASK); /*mask off waitstate bits*/ CONFIG_WRITE_WORD(PICR2, val | PICR2_CF_SNOOP_WS_1WS | PICR2_CF_APHASE_WS_1WS); /*1 wait state*/ CONFIG_WRITE_WORD(EUMBBAR, CFG_EUMB_ADDR); #ifndef CFG_RAMBOOT CONFIG_WRITE_WORD(MCCR1, (CFG_ROMNAL << MCCR1_ROMNAL_SHIFT) | - (CFG_ROMFAL << MCCR1_ROMFAL_SHIFT)); + (CFG_ROMFAL << MCCR1_ROMFAL_SHIFT)); #endif CONFIG_WRITE_WORD(MCCR2, CFG_REFINT << MCCR2_REFINT_SHIFT); CONFIG_WRITE_WORD(MCCR3, - (((CFG_BSTOPRE & 0x003c) >> 2) << MCCR3_BSTOPRE2TO5_SHIFT) | - (CFG_REFREC << MCCR3_REFREC_SHIFT) | - (CFG_RDLAT << MCCR3_RDLAT_SHIFT)); + (((CFG_BSTOPRE & 0x003c) >> 2) << MCCR3_BSTOPRE2TO5_SHIFT) | + (CFG_REFREC << MCCR3_REFREC_SHIFT) | + (CFG_RDLAT << MCCR3_RDLAT_SHIFT)); #ifdef CONFIG_CU824 CONFIG_WRITE_WORD(MCCR4, - (CFG_PRETOACT << MCCR4_PRETOACT_SHIFT) | - (CFG_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | - MCCR4_BIT21 | - (CFG_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | - ((CFG_BSTOPRE & 0x0003) <> 6) << MCCR4_BSTOPRE6TO9_SHIFT)); + (CFG_PRETOACT << MCCR4_PRETOACT_SHIFT) | + (CFG_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | + MCCR4_BIT21 | + (CFG_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | + ((CFG_BSTOPRE & 0x0003) <> 6) << MCCR4_BSTOPRE6TO9_SHIFT)); #else CONFIG_WRITE_WORD(MCCR4, - (CFG_PRETOACT << MCCR4_PRETOACT_SHIFT) | - (CFG_ACTTOPRE << MCCR4_ACTTOPRE_SHIFT) | - MCCR4_BIT21 | - (CFG_REGISTERD_TYPE_BUFFER ? MCCR4_REGISTERED: 0) | - ((CFG_BSTOPRE & 0x0003) <> MICR_ADDR_SHIFT) | - (((CFG_BANK1_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | - (((CFG_BANK2_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | - (((CFG_BANK3_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); + ( (CFG_BANK0_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | + (((CFG_BANK1_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | + (((CFG_BANK2_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | + (((CFG_BANK3_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(EMSAR1, - ( (CFG_BANK0_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | - (((CFG_BANK1_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | - (((CFG_BANK2_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | - (((CFG_BANK3_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); + ( (CFG_BANK0_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | + (((CFG_BANK1_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | + (((CFG_BANK2_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | + (((CFG_BANK3_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(MSAR2, - ( (CFG_BANK4_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | - (((CFG_BANK5_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | - (((CFG_BANK6_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | - (((CFG_BANK7_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); + ( (CFG_BANK4_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | + (((CFG_BANK5_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | + (((CFG_BANK6_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | + (((CFG_BANK7_START & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(EMSAR2, - ( (CFG_BANK4_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | - (((CFG_BANK5_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | - (((CFG_BANK6_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | - (((CFG_BANK7_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); + ( (CFG_BANK4_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | + (((CFG_BANK5_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | + (((CFG_BANK6_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | + (((CFG_BANK7_START & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(MEAR1, - ( (CFG_BANK0_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | - (((CFG_BANK1_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | - (((CFG_BANK2_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | - (((CFG_BANK3_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); + ( (CFG_BANK0_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | + (((CFG_BANK1_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | + (((CFG_BANK2_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | + (((CFG_BANK3_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(EMEAR1, - ( (CFG_BANK0_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | - (((CFG_BANK1_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | - (((CFG_BANK2_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | - (((CFG_BANK3_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); + ( (CFG_BANK0_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | + (((CFG_BANK1_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | + (((CFG_BANK2_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | + (((CFG_BANK3_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(MEAR2, - ( (CFG_BANK4_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | - (((CFG_BANK5_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | - (((CFG_BANK6_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | - (((CFG_BANK7_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); + ( (CFG_BANK4_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) | + (((CFG_BANK5_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 8) | + (((CFG_BANK6_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 16) | + (((CFG_BANK7_END & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT) << 24)); CONFIG_WRITE_WORD(EMEAR2, - ( (CFG_BANK4_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | - (((CFG_BANK5_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | - (((CFG_BANK6_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | - (((CFG_BANK7_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); + ( (CFG_BANK4_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) | + (((CFG_BANK5_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 8) | + (((CFG_BANK6_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 16) | + (((CFG_BANK7_END & MICR_EADDR_MASK) >> MICR_EADDR_SHIFT) << 24)); CONFIG_WRITE_BYTE(ODCR, CFG_ODCR); CONFIG_WRITE_BYTE(MBER, - CFG_BANK0_ENABLE | - (CFG_BANK1_ENABLE << 1) | - (CFG_BANK2_ENABLE << 2) | - (CFG_BANK3_ENABLE << 3) | - (CFG_BANK4_ENABLE << 4) | - (CFG_BANK5_ENABLE << 5) | - (CFG_BANK6_ENABLE << 6) | - (CFG_BANK7_ENABLE << 7)); + CFG_BANK0_ENABLE | + (CFG_BANK1_ENABLE << 1) | + (CFG_BANK2_ENABLE << 2) | + (CFG_BANK3_ENABLE << 3) | + (CFG_BANK4_ENABLE << 4) | + (CFG_BANK5_ENABLE << 5) | + (CFG_BANK6_ENABLE << 6) | + (CFG_BANK7_ENABLE << 7)); /* ! Wait 200us before initialize other registers */ /*FIXME: write a decent udelay wait */ __asm__ __volatile__( - " mtctr %0 \n \ - 0: bdnz 0b\n" + " mtctr %0 \n \ + 0: bdnz 0b\n" : : "r" (0x10000)); CONFIG_READ_WORD(MCCR1, val); - CONFIG_WRITE_WORD(MCCR1, val | MCCR1_MEMGO); //set memory access going + CONFIG_WRITE_WORD(MCCR1, val | MCCR1_MEMGO); /* set memory access going */ __asm__ __volatile__("eieio"); #endif /* CONFIG_MOUSSE, CONFIG_SANDPOINT */ @@ -158,21 +159,21 @@ cpu_init_f (void) struct MPC107_s{ unsigned int iobase; char desc[120]; -} MPC107Regs[] ={ +} MPC107Regs[] ={ {BMC_BASE+0x0, "MPC107 Vendor/Device ID"}, {BMC_BASE+0x4, "MPC107 PCI Command/Status Register"}, {BMC_BASE+0x8, "MPC107 Revision"}, {BMC_BASE+0xC, "MPC107 Cache Line Size"}, {BMC_BASE+0x10, "MPC107 LMBAR"}, - {BMC_BASE+0x14, "MPC8240 PCSR"}, + {BMC_BASE+0x14, "MPC8240 PCSR"}, {BMC_BASE+0xA8, "MPC8240 PICR1"}, {BMC_BASE+0xAC, "MPC8240 PICR2"}, - {BMC_BASE+0x46, "MPC8240 PACR"}, + {BMC_BASE+0x46, "MPC8240 PACR"}, {BMC_BASE+0x310, "MPC8240 ITWR"}, {BMC_BASE+0x300, "MPC8240 OMBAR"}, {BMC_BASE+0x308, "MPC8240 OTWR"}, {BMC_BASE+0x14, "MPC107 Peripheral Control and Status Register"}, - {BMC_BASE+0x78, "MPC107 EUMBAR"}, + {BMC_BASE+0x78, "MPC107 EUMBAR"}, {BMC_BASE+0xC0, "MPC107 Processor Bus Error Status"}, {BMC_BASE+0xC4, "MPC107 PCI Bus Error Status"}, {BMC_BASE+0xC8, "MPC107 Processor/PCI Error Address"}, @@ -182,7 +183,7 @@ struct MPC107_s{ {BMC_BASE+0xF8, "MPC107 MCCR3 Register"}, {BMC_BASE+0xFC, "MPC107 MCCR4 Register"} }; -#define N_MPC107_Regs (sizeof(MPC107Regs)/sizeof(MPC107Regs[0])) +#define N_MPC107_Regs (sizeof(MPC107Regs)/sizeof(MPC107Regs[0])) #endif /* INCLUDE_MPC107_REPORT */ #endif /* CONFIG_MOUSSE */ @@ -204,20 +205,20 @@ cpu_init_r (bd_t *bd) mpc8240_mpc107_setreg(EUMBBAR, EUMBBAR_VAL); /* MOT/SPS: Issue #10002, PCI (FD Alias enable)*/ - mpc8240_mpc107_setreg(AMBOR, 0x000000C0); + mpc8240_mpc107_setreg(AMBOR, 0x000000C0); + - #ifdef INCLUDE_MPC107_REPORT /* Check MPC8240 PCI Device and Vendor ID */ while((tmp = mpc8240_mpc107_getreg(BMC_BASE)) != 0x31057){ - printf(" MPC107: offset=0x%x, val = 0x%x\n", BMC_BASE, tmp); + printf(" MPC107: offset=0x%x, val = 0x%x\n", BMC_BASE, tmp); } for( i = 0; i < N_MPC107_Regs; i++){ - printf(" 0x%x/%s = 0x%x\n", MPC107Regs[i].iobase, + printf(" 0x%x/%s = 0x%x\n", MPC107Regs[i].iobase, MPC107Regs[i].desc, mpc8240_mpc107_getreg(MPC107Regs[i].iobase)); } - + printf("IBAT0L = 0x%08X\n", mfspr(IBAT0L)); printf("IBAT0U = 0x%08X\n", mfspr(IBAT0U)); printf("IBAT1L = 0x%08X\n", mfspr(IBAT1L)); diff --git a/cpu/mpc8xx/Makefile b/cpu/mpc8xx/Makefile index 763c40d..3e33bab 100644 --- a/cpu/mpc8xx/Makefile +++ b/cpu/mpc8xx/Makefile @@ -28,10 +28,10 @@ include $(TOPDIR)/config.mk LIB = lib$(CPU).a START = start.o kgdb.o -OBJS = traps.o serial.o cpu.o cpu_init.o speed.o \ - commproc.o interrupts.o fec.o scc.o spi.o \ - i2c.o soft_i2c.o video.o wlkbd.o status_led.o \ - bedbug_860.o upatch.o +OBJS = bedbug_860.o commproc.o cpu.o cpu_init.o \ + fec.o i2c.o interrupts.o lcd.o scc.o \ + serial.o soft_i2c.o speed.o spi.o status_led.o\ + traps.o upatch.o video.o wlkbd.o all: .depend $(START) $(LIB) diff --git a/cpu/mpc8xx/i2c.c b/cpu/mpc8xx/i2c.c index 3d3528c..6531a3a 100644 --- a/cpu/mpc8xx/i2c.c +++ b/cpu/mpc8xx/i2c.c @@ -488,12 +488,8 @@ int i2c_doio(i2c_state_t *state) txbd = ((I2C_BD*)state->txbd) - 1; PRINTD(("[I2C] Transmitting...(txbd=0x%08lx)\n", (ulong)txbd)); while((txbd->status & BD_SC_READY) && (j++ < TOUT_LOOP)) { - if (tstc()) { - switch (getc()) { - case '\0': - case 0x03: /* ^C - Control C */ - return (-1); - } + if (ctrlc()) { + return (-1); } __asm__ __volatile__ ("eieio"); } @@ -503,12 +499,8 @@ int i2c_doio(i2c_state_t *state) rxbd = ((I2C_BD*)state->rxbd) - 1; PRINTD(("[I2C] Receiving...(rxbd=0x%08lx)\n", (ulong)rxbd)); while((rxbd->status & BD_SC_EMPTY) && (j++ < TOUT_LOOP)) { - if (tstc()) { - switch (getc()) { - case '\0': - case 0x03: /* ^C - Control C */ - return (-1); - } + if (ctrlc()) { + return (-1); } __asm__ __volatile__ ("eieio"); } @@ -551,6 +543,8 @@ int i2c_doio(i2c_state_t *state) int i2c_read(uchar *addr, int alen, uchar *buffer, int len) { + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); i2c_state_t state; int rc; @@ -558,19 +552,22 @@ i2c_read(uchar *addr, int alen, uchar *buffer, int len) rc = i2c_send(&state, *addr, 0, I2CF_START_COND, alen - 1, addr + 1); if (rc != 0) { - printf("i2c_read: i2c_send failed (%d)\n", rc); + if (idata->have_console) + printf("i2c_read: i2c_send failed (%d)\n", rc); return 1; } rc = i2c_receive(&state, *addr, 0, I2CF_STOP_COND, len, buffer); if (rc != 0) { - printf("i2c_read: i2c_receive failed (%d)\n", rc); + if (idata->have_console) + printf("i2c_read: i2c_receive failed (%d)\n", rc); return 1; } rc = i2c_doio(&state); if (rc != 0) { - printf("i2c_read: i2c_doio failed (%d)\n", rc); + if (idata->have_console) + printf("i2c_read: i2c_doio failed (%d)\n", rc); return 1; } return 0; @@ -579,6 +576,8 @@ i2c_read(uchar *addr, int alen, uchar *buffer, int len) int i2c_write(uchar *addr, int alen, uchar *buffer, int len) { + init_data_t *idata = + (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); i2c_state_t state; int rc; @@ -586,19 +585,22 @@ i2c_write(uchar *addr, int alen, uchar *buffer, int len) rc = i2c_send(&state, *addr, 0, I2CF_START_COND, alen - 1, addr + 1); if (rc != 0) { - printf("i2c_write: first i2c_send failed (%d)\n", rc); + if (idata->have_console) + printf("i2c_write: first i2c_send failed (%d)\n", rc); return 1; } rc = i2c_send(&state, 0, 0, I2CF_STOP_COND, len, buffer); if (rc != 0) { - printf("i2c_write: second i2c_send failed (%d)\n", rc); + if (idata->have_console) + printf("i2c_write: second i2c_send failed (%d)\n", rc); return 1; } rc = i2c_doio(&state); if (rc != 0) { - printf("i2c_write: i2c_doio failed (%d)\n", rc); + if (idata->have_console) + printf("i2c_write: i2c_doio failed (%d)\n", rc); return 1; } return 0; diff --git a/cpu/mpc8xx/start.S b/cpu/mpc8xx/start.S index a899a93..f59b335 100644 --- a/cpu/mpc8xx/start.S +++ b/cpu/mpc8xx/start.S @@ -333,11 +333,11 @@ transfer_to_handler: rfi /* jump to handler, enable MMU */ int_return: - mfmsr r29 /* Disable interrupts */ + mfmsr r29 /* Disable interrupts */ li r4,0 ori r4,r4,MSR_EE andc r29,r29,r4 - SYNC /* Some chip revs need this... */ + SYNC /* Some chip revs need this... */ mtmsr r29 SYNC lwz r2,_CTR(r1) @@ -352,7 +352,7 @@ int_return: REST_10GPRS(13, r1) REST_8GPRS(23, r1) REST_GPR(31, r1) - lwz r2,_NIP(r1) /* Restore environment */ + lwz r2,_NIP(r1) /* Restore environment */ lwz r0,_MSR(r1) mtspr SRR0,r2 mtspr SRR1,r0 @@ -661,7 +661,7 @@ trap_init: lwz r7, GOT(_start) lwz r8, GOT(_end_of_vectors) - rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */ + rlwinm r9, r7, 0, 22, 31 /* _start & 0x3FF */ cmplw 0, r7, r8 bgelr /* return if r7>=r8 - just in case */ diff --git a/include/config_Sandpoint8240.h b/include/config_Sandpoint8240.h index eced9fd..f9b22d7 100644 --- a/include/config_Sandpoint8240.h +++ b/include/config_Sandpoint8240.h @@ -21,26 +21,24 @@ #define USE_DINK32 1 #define CONFIG_BAUDRATE 115200 -#define CONFIG_DRAM_SPEED 100 /* MHz */ -#define CONFIG_BOOTCOMMAND "" /* autoboot command */ -#define CONFIG_BOOTARGS " " +#define CONFIG_DRAM_SPEED 100 /* MHz */ -#define CONFIG_COMMANDS (CONFIG_CMD_DFL & ~CFG_CMD_NET) +#define CONFIG_COMMANDS (CONFIG_CMD_DFL & ~CFG_CMD_NET) -/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ +/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ #include /* * Miscellaneous configurable options */ -#define CFG_LONGHELP 1 /* undef to save memory */ -#define CFG_PROMPT ":>" /* Monitor Command Prompt */ -#define CFG_CBSIZE 256 /* Console I/O Buffer Size */ -#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ -#define CFG_MAXARGS 8 /* max number of command args */ -#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */ -#define CFG_LOAD_ADDR 0x00100000 /* default load address */ +#define CFG_LONGHELP 1 /* undef to save memory */ +#define CFG_PROMPT "=> " /* Monitor Command Prompt */ +#define CFG_CBSIZE 256 /* Console I/O Buffer Size */ +#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ +#define CFG_MAXARGS 8 /* max number of command args */ +#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */ +#define CFG_LOAD_ADDR 0x00100000 /* default load address */ /*----------------------------------------------------------------------- * Start addresses for the final memory configuration @@ -50,38 +48,38 @@ #define CFG_SDRAM_BASE 0x00000000 #if defined (USE_DINK32) - #define CFG_MONITOR_LEN 0x00020000 - #define CFG_MONITOR_BASE 0x00090000 - #define CFG_RAMBOOT 1 - #define CFG_INIT_RAM_ADDR (CFG_MONITOR_BASE + CFG_MONITOR_LEN) - #define CFG_INIT_RAM_END (CFG_INIT_RAM_ADDR + 0x10000) /* End of used area in DPRAM */ - #define CFG_INIT_DATA_SIZE 256 /* size in bytes reserved for initial data */ - #define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE) - #define CFG_INIT_SP_OFFSET CFG_INIT_DATA_OFFSET +#define CFG_MONITOR_LEN 0x00020000 +#define CFG_MONITOR_BASE 0x00090000 +#define CFG_RAMBOOT 1 +#define CFG_INIT_RAM_ADDR (CFG_MONITOR_BASE + CFG_MONITOR_LEN) +#define CFG_INIT_RAM_END (CFG_INIT_RAM_ADDR + 0x10000) +#define CFG_INIT_DATA_SIZE 256 /* size in bytes reserved for initial data */ +#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE) +#define CFG_INIT_SP_OFFSET CFG_INIT_DATA_OFFSET #else - #undef CFG_RAMBOOT +#undef CFG_RAMBOOT #endif #define CFG_FLASH_BASE 0xFFF00000 -#define CFG_FLASH_SIZE (512 * 1024) /* sandpoint has tiny eeprom */ -#define CFG_ENV_IS_IN_FLASH 1 -#define CFG_ENV_OFFSET 0x00008000 /* Offset of Environment Sector */ +#define CFG_FLASH_SIZE (512 * 1024) /* sandpoint has tiny eeprom */ +#define CFG_ENV_IS_IN_FLASH 1 +#define CFG_ENV_OFFSET 0x00008000 /* Offset of Environment Sector */ #define CFG_ENV_SIZE 0x00004000 /* Total Size of Environment Sector */ -#define CFG_MALLOC_LEN (512 << 10) /* Reserve 512 kB for malloc() */ +#define CFG_MALLOC_LEN (512 << 10) /* Reserve 512 kB for malloc() */ -#define CFG_MEMTEST_START 0x00000000 /* memtest works on */ -#define CFG_MEMTEST_END 0x04000000 /* 0 ... 32 MB in DRAM */ +#define CFG_MEMTEST_START 0x00000000 /* memtest works on */ +#define CFG_MEMTEST_END 0x04000000 /* 0 ... 32 MB in DRAM */ #define CFG_EUMB_ADDR 0xFC000000 #define CFG_ISA_MEM 0xFD000000 #define CFG_ISA_IO 0xFE000000 -#define CFG_FLASH_RANGE_BASE 0xFF000000 /* flash memory address range */ +#define CFG_FLASH_RANGE_BASE 0xFF000000 /* flash memory address range */ #define CFG_FLASH_RANGE_SIZE 0x01000000 -#define FLASH_BASE0_PRELIM 0xFFF80000 /* sandpoint flash */ -#define FLASH_BASE1_PRELIM 0xFF000000 /* PMC onboard flash*/ +#define FLASH_BASE0_PRELIM 0xFFF80000 /* sandpoint flash */ +#define FLASH_BASE1_PRELIM 0xFF000000 /* PMC onboard flash */ #define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } #define CFG_FLASH_BANKS { FLASH_BASE0_PRELIM } @@ -91,14 +89,14 @@ */ -#define CFG_WINBOND_83C553 1 /*has a winbond bridge */ -#define CFG_USE_WINBOND_IDE 0 /*use winbond 83c553 internal ide controller */ -#define CFG_WINBOND_ISA_CFG_ADDR 0x80005800 /*pci-isa bridge config addr */ -#define CFG_WINBOND_IDE_CFG_ADDR 0x80005900 /*ide config addr */ -#define CFG_NS87308_BADDR_10 1 +#define CFG_WINBOND_83C553 1 /*has a winbond bridge */ +#define CFG_USE_WINBOND_IDE 0 /*use winbond 83c553 internal IDE ctrlr */ +#define CFG_WINBOND_ISA_CFG_ADDR 0x80005800 /*pci-isa bridge config addr */ +#define CFG_WINBOND_IDE_CFG_ADDR 0x80005900 /*ide config addr */ +#define CFG_NS87308_BADDR_10 1 -#define CFG_NS_PC87308UL 1 /* Nat Semi super-io controller on ISA bus */ +#define CFG_NS_PC87308UL 1 /* Nat Semi super-io controller on ISA bus */ /* * Low Level Configuration Settings @@ -107,20 +105,20 @@ */ -#define CFG_ROMNAL 7 /*rom/flash next access time*/ -#define CFG_ROMFAL 11 /*rom/flash access time*/ +#define CFG_ROMNAL 7 /*rom/flash next access time */ +#define CFG_ROMFAL 11 /*rom/flash access time */ -#define CFG_REFINT 430 /* no of clock cycles between CBR refresh cycles*/ +#define CFG_REFINT 430 /* no of clock cycles between CBR refresh cycles */ /* the following are for SDRAM only*/ -#define CFG_BSTOPRE 121 /* Burst To Precharge, sets open page interval */ -#define CFG_REFREC 8 /* Refresh to activate interval */ -#define CFG_RDLAT 3 /* data latency from read command */ -#define CFG_PRETOACT 3 /* Precharge to activate interval */ -#define CFG_ACTTOPRE 5 /* Activate to Precharge interval */ -#define CFG_ACTTORW 3 /* Activate to R/W */ -#define CFG_SDMODE_CAS_LAT 2 /* SDMODE CAS latency */ -#define CFG_SDMODE_WRAP 0 /* SDMODE wrap type */ -#define CFG_SDMODE_BURSTLEN 2 /* SDMODE Burst length 2=4, 3=8 */ +#define CFG_BSTOPRE 121 /* Burst To Precharge, sets open page interval */ +#define CFG_REFREC 8 /* Refresh to activate interval */ +#define CFG_RDLAT 3 /* data latency from read command */ +#define CFG_PRETOACT 3 /* Precharge to activate interval */ +#define CFG_ACTTOPRE 5 /* Activate to Precharge interval */ +#define CFG_ACTTORW 3 /* Activate to R/W */ +#define CFG_SDMODE_CAS_LAT 2 /* SDMODE CAS latency */ +#define CFG_SDMODE_WRAP 0 /* SDMODE wrap type */ +#define CFG_SDMODE_BURSTLEN 2 /* SDMODE Burst length 2=4, 3=8 */ #define CFG_REGISTERD_TYPE_BUFFER 1 @@ -152,30 +150,31 @@ */ #define CFG_BANK_ENABLE 0x01 -#define CFG_ODCR 0xff /* configures line driver impedances, - see 8240 book for bit definitions */ -#define CFG_PGMAX 0x32 /* how long the 8240 retains the currently accessed page in memory - see 8240 book for details*/ +#define CFG_ODCR 0xff /* configures line driver impedances, */ + /* see 8240 book for bit definitions */ +#define CFG_PGMAX 0x32 /* how long the 8240 retains the */ + /* currently accessed page in memory */ + /* see 8240 book for details */ /* * For booting Linux, the board info and command line data * have to be in the first 8 MB of memory, since this is * the maximum mapped by the Linux kernel during initialization. */ -#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ +#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ /*----------------------------------------------------------------------- * FLASH organization */ -#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */ -#define CFG_MAX_FLASH_SECT 20 /* max number of sectors on one chip */ +#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */ +#define CFG_MAX_FLASH_SECT 20 /* max number of sectors on one chip */ -#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */ -#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */ +#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */ +#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */ /*----------------------------------------------------------------------- * Cache Configuration */ -#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */ +#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */ @@ -184,13 +183,13 @@ * * Boot Flags */ -#define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */ -#define BOOTFLAG_WARM 0x02 /* Software reboot */ +#define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */ +#define BOOTFLAG_WARM 0x02 /* Software reboot */ /* values according to the manual */ -#define CONFIG_DRAM_50MHZ 1 +#define CONFIG_DRAM_50MHZ 1 #define CONFIG_SDRAM_50MHZ #undef NR_8259_INTS @@ -200,4 +199,4 @@ #define CONFIG_DISK_SPINUP_TIME 1000000 -#endif /* __CONFIG_H */ +#endif /* __CONFIG_H */ diff --git a/include/config_lwmon.h b/include/config_lwmon.h index d823153..faa44b6 100644 --- a/include/config_lwmon.h +++ b/include/config_lwmon.h @@ -36,6 +36,9 @@ #define CONFIG_MPC823 1 /* This is a MPC823E CPU */ #define CONFIG_LWMON 1 /* ...on a LWMON board */ +#define CONFIG_LCD 1 /* use LCD controller ... */ +#define CONFIG_HLD1045 1 /* ... with a HLD1045 display */ + #if 1 #define CONFIG_8xx_CONS_SMC2 1 /* Console is on SMC2 */ #else diff --git a/include/devices.h b/include/devices.h index 7542655..97cf63a 100644 --- a/include/devices.h +++ b/include/devices.h @@ -12,7 +12,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -27,76 +27,82 @@ #define _DEVICES_H_ /* -** CONSOLE DEVICES -*/ + * CONSOLE DEVICES + */ -#define DEV_FLAGS_INPUT 0x00000001 // The device can be used as input console -#define DEV_FLAGS_OUTPUT 0x00000002 // The device can be used as output console -#define DEV_FLAGS_SYSTEM 0x80000000 // The device is a system device -#define DEV_EXT_VIDEO 0x00000001 // Video extensions supported +#define DEV_FLAGS_INPUT 0x00000001 /* Device can be used as input console */ +#define DEV_FLAGS_OUTPUT 0x00000002 /* Device can be used as output console */ +#define DEV_FLAGS_SYSTEM 0x80000000 /* Device is a system device */ +#define DEV_EXT_VIDEO 0x00000001 /* Video extensions supported */ -// Device informations +/* Device informations */ typedef struct { - int flags, // Device flags: input/output/system - ext; // Supported extensions - char name[8]; // Device name + int flags; /* Device flags: input/output/system */ + int ext; /* Supported extensions */ + char name[8]; /* Device name */ -// GENERAL functions +/* GENERAL functions */ - int (*start)(void); // To start the device - int (*stop)(void); // To stop the device + int (*start) (void); /* To start the device */ + int (*stop) (void); /* To stop the device */ -// OUTPUT functions +/* OUTPUT functions */ - void (*putc)(const char c) ; // To put a char - void (*puts)(const char *s) ; // To put a string (accelerator) + void (*putc) (const char c); /* To put a char */ + void (*puts) (const char *s); /* To put a string (accelerator) */ -// INPUT functions +/* INPUT functions */ - int (*tstc)(void) ; // To test if a char is ready... - int (*getc)(void) ; // To get that char + int (*tstc) (void); /* To test if a char is ready... */ + int (*getc) (void); /* To get that char */ -// Other functions +/* Other functions */ - void *priv ; // Private extensions -} device_t ; + void *priv; /* Private extensions */ +} device_t; /* -** VIDEO EXTENSIONS -*/ - + * VIDEO EXTENSIONS + */ #define VIDEO_FORMAT_RGB_INDEXED 0x0000 #define VIDEO_FORMAT_RGB_DIRECTCOLOR 0x0001 #define VIDEO_FORMAT_YUYV_4_4_4 0x0010 #define VIDEO_FORMAT_YUYV_4_2_2 0x0011 typedef struct { - void *address ; // Address of framebuffer - unsigned short - width, // Horizontal resolution - height; // Vertical resolution - unsigned char - format, // Format - colors; // Colors number or color depth - - void (*setcolreg)(int,int,int,int); - void (*getcolreg)(int, void *); -} video_ext_t ; + void *address; /* Address of framebuffer */ + ushort width; /* Horizontal resolution */ + ushort height; /* Vertical resolution */ + uchar format; /* Format */ + uchar colors; /* Colors number or color depth */ + void (*setcolreg) (int, int, int, int); + void (*getcolreg) (int, void *); +} video_ext_t; /* -** VARIABLES -*/ - -extern list_t devlist; -extern device_t *stdio_devices[] ; -extern char *stdio_names[MAX_FILES] ; + * VARIABLES + */ +extern list_t devlist; +extern device_t *stdio_devices[]; +extern char *stdio_names[MAX_FILES]; /* -** PROTOTYPES -*/ - -int device_register (device_t *dev); -int devices_init (ulong); -int devices_done(void); + * PROTOTYPES + */ +int device_register (device_t * dev); +int devices_init (bd_t *, ulong); +int devices_done (void); +#ifdef CONFIG_LCD +int drv_lcd_init (bd_t *); +#endif +#ifdef CONFIG_VIDEO +int drv_video_init (void); +#endif +#ifdef CONFIG_WL_4PPM_KEYBOARD +int drv_wlkbd_init (void); +#endif +#ifdef CONFIG_ISA_KEYBOARD +int drv_isa_kbd_init (void); +#endif #endif /* _DEVICES_H_ */ diff --git a/include/ppcboot.h b/include/ppcboot.h index 5a32b93..5ac6835 100644 --- a/include/ppcboot.h +++ b/include/ppcboot.h @@ -154,6 +154,9 @@ typedef struct init_data { #if defined(CONFIG_SANDPOINT) void * console_addr; #endif +#ifdef CONFIG_LCD + unsigned long lcd_base; /* Base address of LCD frambuffer mem */ +#endif } init_data_t; /* @@ -436,7 +439,10 @@ void set_timer (ulong t); void enable_interrupts (void); int disable_interrupts (void); -/* $(CPU)/traps.c */ +/* $(CPU)/.../lcd.c */ +#ifdef CONFIG_LCD +ulong lcd_setmem (ulong); +#endif /* CONFIG_LCD */ /* ppc/ticks.S */ unsigned long long get_ticks(void); diff --git a/include/video.h b/include/video.h index 568f583..efcc682 100644 --- a/include/video.h +++ b/include/video.h @@ -9,7 +9,7 @@ #ifndef _VIDEO_H_ #define _VIDEO_H_ -// Video functions +/* Video functions */ int video_init (void *videobase); void video_putc (const char c); diff --git a/include/video_easylogo.h b/include/video_easylogo.h index f11e849..1e00818 100644 --- a/include/video_easylogo.h +++ b/include/video_easylogo.h @@ -7,20 +7,20 @@ ** This utility is still under construction! */ -// Dont use print here 'cause video console is not initialized! - #ifndef _EASYLOGO_H_ #define _EASYLOGO_H_ -//#define ENABLE_ASCII_BANNERS +#if 0 +#define ENABLE_ASCII_BANNERS +#endif typedef struct { unsigned char *data; - int width, - height, - bpp, - pixel_size, - size; -} fastimage_t ; + int width; + int height; + int bpp; + int pixel_size; + int size; +} fastimage_t ; -#endif +#endif /* _EASYLOGO_H_ */ diff --git a/tools/Makefile b/tools/Makefile index 153eaf9..ca06672 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,5 +1,5 @@ # -# (C) Copyright 2000 +# (C) Copyright 2000, 2001 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # See file CREDITS for list of people who contributed to this @@ -23,9 +23,17 @@ include $(TOPDIR)/config.mk -BINS = img2srec mkimage envcrc gen_eth_addr +BINS = img2srec mkimage envcrc gen_eth_addr bmp_logo -OBJS = img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o +OBJS = img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o + +LOGO_H = $(TOPDIR)/include/bmp_logo.h + +ifeq ($(LOGO_BMP),) +LOGO_BMP= logos/denx.bmp +endif + +#------------------------------------------------------------------------- HOSTARCH := $(shell uname -m | \ sed -e s/i.86/i386/ \ @@ -55,7 +63,7 @@ CC = $(HOSTCC) STRIP = $(HOSTSTRIP) MAKEDEPEND = makedepend -all: .depend $(BINS) subdirs +all: .depend $(BINS) $(LOGO_H) subdirs envcrc: envcrc.o crc32.o environment.o $(CC) $(CFLAGS) -o $@ $^ @@ -68,10 +76,16 @@ img2srec: img2srec.o $(STRIP) $@ mkimage: mkimage.o crc32.o - $(CC) -g $(CFLAGS) -o $@ $^ + $(CC) $(CFLAGS) -o $@ $^ + $(STRIP) $@ gen_eth_addr: gen_eth_addr.o - $(CC) -g $(CFLAGS) -o $@ $^ + $(CC) $(CFLAGS) -o $@ $^ + $(STRIP) $@ + +bmp_logo: bmp_logo.o + $(CC) $(CFLAGS) -o $@ $^ + $(STRIP) $@ envcrc.o: envcrc.c $(CC) -g $(CFLAGS) -c $< @@ -91,6 +105,9 @@ subdirs: crc32.c: ln -s ../ppc/crc32.c crc32.c +$(LOGO_H): bmp_logo $(LOGO_BMP) + bmp_logo $(LOGO_BMP) >$@ + ######################################################################### .depend: Makefile $(OBJS:.o=.c)