diff -urN hermit-1.3/Makefile hermit/Makefile --- hermit-1.3/Makefile Fri Mar 30 03:31:27 2001 +++ hermit/Makefile Tue Jul 10 13:53:11 2001 @@ -2,7 +2,7 @@ # Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. # -export TARGET := ep7211 +export TARGET := cs89712 export PROFILE := export INSTALL := install diff -urN hermit-1.3/include/cs89712/cs89712.h hermit/include/cs89712/cs89712.h --- hermit-1.3/include/cs89712/cs89712.h Wed Dec 31 17:00:00 1969 +++ hermit/include/cs89712/cs89712.h Tue Jul 10 13:25:42 2001 @@ -0,0 +1,293 @@ +/* + * linux/include/asm-arm/arch-cs89712/cs89712.h + * + * Written 1998,1999 by Werner Almesberger + * Modified 1999 by Ben Williamson, from clps7110.h + * + * This file contains the hardware definitions of the cs89712 chip + */ + +#ifndef _ASM_ARCH_CS89712_H +#define _ASM_ARCH_CS89712_H + +/* + * CS89712 internal registers + * + * The names will almost certainly clash with something else ... so we'll + * probably have to prefix them with CS89712_ or something equally ugly later. + */ + +#define PADR 0x0000 /* Port A Data register ---------------------------- */ +#define PBDR 0x0001 /* Port B Data register ---------------------------- */ +#define PDDR 0x0003 /* Port D Data register ---------------------------- */ +#define PADDR 0x0040 /* Port A Data Direction register ------------------ */ +#define PBDDR 0x0041 /* Port B Data Direction register ------------------ */ +#define PDDDR 0x0043 /* Port D Data Direction register ------------------ */ +#define PEDR 0x0080 /* Port E Data register ---------------------------- */ +#define PEDDR 0x00c0 /* Port E Data Direction register ------------------ */ + +#define SYSCON1 0x0100 /* System Control register ------------------------- */ +#define KBDSCAN 0x0000000f /* Keyboard scan */ +#define KBSC_HI 0x0 /* All driven high */ +#define KBSC_LO 0x1 /* All driven low */ +#define KBSC_X 0x2 /* All high impedance */ +#define KBSC_COL0 0x8 /* Column 0 high, others high impedance */ +#define KBSC_COL1 0x9 /* Column 1 high, others high impedance */ +#define KBSC_COL2 0xa /* Column 2 high, others high impedance */ +#define KBSC_COL3 0xb /* Column 3 high, others high impedance */ +#define KBSC_COL4 0xc /* Column 4 high, others high impedance */ +#define KBSC_COL5 0xd /* Column 5 high, others high impedance */ +#define KBSC_COL6 0xe /* Column 6 high, others high impedance */ +#define KBSC_COL7 0xf /* Column 7 high, others high impedance */ +#define TC1M 0x00000010 /* TC1 mode (0: free-running, 1: prescale) */ +#define TC1S 0x00000020 /* TC1 clock source (0: 2 kHz, 1: 512 kHz) */ +#define TC2M 0x00000040 /* TC2 mode (0: free-running, 1: prescale) */ +#define TC2S 0x00000080 /* TC2 clock source (0: 2 kHz, 1: 512 kHz) */ +#define UART1EN 0x00000100 /* Internal UART enable */ +#define BZTOG 0x00000200 /* Drive buzzer directly */ +#define BZMOD 0x00000400 /* Buzzer drive mode (0: BZTOG, 1: TC1 under-flow)*/ +#define DBGEN 0x00000800 /* Debug mode */ +#define LCDEN 0x00001000 /* LCD enable */ +#define CDENTX 0x00002000 /* Codec interface enable Tx */ +#define CDENRX 0x00004000 /* Codec interface enable Rx */ +#define SIREN 0x00008000 /* HP SIR protocol encoding enable */ +#define ADCKSEL 0x00030000 /* Microwire/SPI peripheral clock speed select */ +#define ADCKSEL_SHIFT 16 +#define ADCS_8 0x0 /* Sample 8 kHz, interface 4 kHz */ +#define ADCS_32 0x1 /* 32/16 kHz */ +#define ADCS_128 0x2 /* 128/64 kHz */ +#define ADCS_256 0x3 /* 256/128 kHz */ +#define EXCKEN 0x00040000 /* External expansion clock enable */ +#define WAKEDIS 0x00080000 /* Disable switch-on through wake-up */ +#define IRTXM 0x00100000 /* IrDA Tx mode (0: 3/16 of rate, 1: 1.63 us) */ + +#define SYSFLG1 0x0140 /* System Status Flags register -------------------- */ +#define MCDR 0x00000001 /* Media changed direct read */ +#define DCDET 0x00000002 /* Main adapter is powering the system */ +#define WUDR 0x00000004 /* Wake-up direct read */ +#define WUON 0x00000008 /* Left standby on wake-up */ +#define DID 0x000000f0 /* Display ID nibble */ +#define DID_SHIFT 4 +#define CTS 0x00000100 /* UART CTS */ +#define DSR 0x00000200 /* UART DSR */ +#define DCD 0x00000400 /* UART DCD */ +#define UBUSY1 0x00000800 /* UART transmitter busy */ +#define NBFLG 0x00001000 /* New battery flag */ +#define RSTFLG 0x00002000 /* Reset flag */ +#define PFFLG 0x00004000 /* Power fail flag */ +#define CLDFLG 0x00008000 /* Cold start flag */ +#define RTCDIV 0x003f0000 /* 64 Hz ticks since last RTC increment */ +#define RTCDIV_SHIFT 16 +#define URXFE1 0x00400000 /* UART receiver FIFO empty */ +#define UTXFF1 0x00800000 /* UART transmit FIFO full */ +#define CRXFE 0x01000000 /* Codec Rx FIFO empty */ +#define CTXFF 0x02000000 /* Codec Tx FIFO full */ +#define SSIBUSY 0x04000000 /* Synchronous serial interface busy */ +#define BOOTBIT 0x18000000 /* Initial bus width from PE[1:0] */ +#define BOOTBIT_32 0x00000000 /* 32 bits */ +#define BOOTBIT_8 0x08000000 /* 8 bits */ +#define BOOTBIT_16 0x10000000 /* 16 bits */ +#define VERID 0xc0000000 /* Version ID */ +#define VERID_SHIFT 30 + +#define MEMCFG1 0x0180 /* Memory Configuration register 1 ----------------- */ +#define MEMCFG2 0x01c0 /* Memory Configuration register 2 ----------------- */ +#define CS_BW 0x03 /* Bus width */ +#define CS_BW_BUS32_E0 0 /* 32 bit if E=0 */ +#define CS_BW_BUS16_E0 1 /* 16 bit if E=0 */ +#define CS_BW_BUS8_E0 2 /* 8 bit if E=0 */ +#define CS_BW_BUS8_E1 0 /* 8 bit if E=1 */ +#define CS_BW_BUS32_E1 2 /* 32 bit if E=1 */ +#define CS_BW_BUS16_E1 3 /* 16 bit if E=1 */ +#define CS_BW_BUS16_E2 0 /* 16 bit if E=2 */ +#define CS_BW_BUS32_E2 1 /* 32 bit if E=2 */ +#define CS_BW_BUS8_E2 3 /* 8 bit if E=2 */ +#define CS_RAWT 0x0c /* Random Access Wait State */ +#define CS_RAWT_SHIFT 2 /* WS = 4-N; speed = 50+50*WS ns */ +#define CS_SAWR 0x30 /* Sequential Access Wait State */ +#define CS_SAWR_SHIFT 4 /* WS = 3-N; speed[WS] = 40,80,120,150 ns */ +#define CS_SQAEN 0x40 /* Sequential Access Enable */ +#define CS_CLKEN 0x80 /* Expansion Clock Enable */ +#define DRFPR 0x0200 + +#define INTSR1 0x0240 /* Interrupt Status register ----------------------- */ +#define EXTFIQ 0x00000001 /* External fast interrupt */ +#define BLINT 0x00000002 /* Battery low interrupt */ +#define WEINT 0x00000004 /* Watch dog expired interrupt */ +#define MCINT 0x00000008 /* Media changed interrupt */ +#define CSINT 0x00000010 /* Codec sound interrupt */ +#define EINT1 0x00000020 /* External interrupt 1 */ +#define EINT2 0x00000040 /* External interrupt 2 */ +#define EINT3 0x00000080 /* External interrupt 3 */ +#define TC1OI 0x00000100 /* TC1 under-flow interrupt */ +#define TC2OI 0x00000200 /* TC2 under-flow interrupt */ +#define RTCMI 0x00000400 /* RTC compare match interrupt */ +#define TINT 0x00000800 /* 64-Hz tick interrupt */ +#define UTXINT1 0x00001000 /* Internal UART transmit FIFO half-empty intr. */ +#define URXINT1 0x00002000 /* Internal UART receive FIFO half-full interrupt */ +#define UMSINT 0x00004000 /* Internal UART modem status changed interrupt */ +#define SSEOTI 0x00008000 /* Synchronous serial interface end-of-transfer */ + +#define INTMR1 0x0280 /* Interrupt Mask register ------------------------- */ + +#define LCDCON 0x02c0 /* LCD Control register ---------------------------- */ +#define VBUFSIZ 0x00001fff /* Video buffer size (bits/128-1) */ +#define LINELEN 0x0007e000 /* Line length (pix/16-1) */ +#define LINELEN_SHIFT 13 +#define PIXPSC 0x01f80000 /* Pixel prescale (526628/pixels-1) */ +#define PIXPSC_SHIFT 19 +#define ACPSC 0x3e000000 /* AC prescale */ +#define ACPSC_SHIFT 25 +#define GSEN 0x40000000 /* Grayscale enable (0: monochrome) */ +#define GSMD 0x80000000 /* Grayscale mode (0: 2 bit, 1: 4 bit) */ + +#define TC1D 0x0300 /* Timer Counter 1 Data register ------------------- */ +#define TC_MASK 0x0000ffff +#define TC2D 0x0340 /* Timer Counter 2 Data register ------------------- */ + +#define RTCDR 0x0380 /* Realtime Clock Data register -------------------- */ + +#define RTCMR 0x03c0 /* Realtime Clock Match register ------------------- */ + +#define PMPCON 0x0400 + +#define CODR 0x0440 /* Codec Interface Data register ------------------- */ + +#define UARTDR1 0x0480 /* UART FIFO Data register ------------------------- */ +#define RX_DATA 0x000000ff /* Rx data */ +#define FRMERR 0x00000100 /* UART framing error */ +#define PARERR 0x00000200 /* UART parity error */ +#define OVERR 0x00000400 /* UART overrun error */ + +#define UBRLCR1 0x04c0 /* UART Bit Rate and Line Control register --------- */ +#define BRDIV 0x00000fff /* Bit rate divisor */ +#define BR_115200 1 +#define BR_57600 3 +#define BR_38400 5 +#define BR_19200 11 +#define BR_9600 23 +#define BR_2400 95 +#define BR_1200 191 +#define BREAK 0x00001000 /* Set Tx high */ +#define PRTEN 0x00002000 /* Parity enable */ +#define EVENPRT 0x00004000 /* Even parity */ +#define XSTOP 0x00008000 /* Extra stop bit */ +#define FIFOEN 0x00010000 /* Enable FIFO */ +#define WRDLEN 0x00030000 /* Word length */ +#define WRDLEN_SHIFT 17 +#define WL_5 0x0 /* 5 bits */ +#define WL_6 0x1 /* 6 bits */ +#define WL_7 0x2 /* 7 bits */ +#define WL_8 0x3 /* 8 bits */ + +#define SYNCIO 0x0500 +#define TXFRMEN 0x00004000 /* Initiate data transfer */ +#define SMCKEN 0x00002000 /* Enable sample clock on SMPLCK */ +#define FRLEN 0x00001f00 /* Frame length */ +#define FRLEN_SHIFT 8 +#define ADCCFB 0x000000ff /* ADC Configuration byte */ +#define ADCRSW 0x0000ffff /* ADC result word */ + +#define PALLSW 0x0540 /* Least-significant 32-bit word of LCD Palette reg. */ +#define PALMSW 0x0580 /* Most-significant 32-bit word of LCD Palette reg. */ + +#define STFCLR 0x05c0 /* Write to clear all start up reason flags -------- */ +#define BLEOI 0x0600 /* Write to clear Battery Low interrupt ------------ */ +#define MCEOI 0x0640 /* Write to clear Media Changed interrupt ---------- */ +#define TEOI 0x0680 /* Write to clear Tick and Watchdog interrupt ------ */ +#define TC1EOI 0x06c0 /* Write to clear TC1 interrupt -------------------- */ +#define TC2EOI 0x0700 /* Write to clear TC2 interrupt -------------------- */ +#define RTCEOI 0x0740 /* Write to clear RTC Match interrupt -------------- */ +#define UMSEOI 0x0780 /* Write to clear UART Modem Status Changed interrupt*/ +#define COEOI 0x07c0 /* Write to clear Codec Sound interrupt ------------ */ +#define HALT 0x0800 /* Write to enter idle state ----------------------- */ +#define STDBY 0x0840 /* Write to standby state -------------------------- */ + +#define FRBADDR 0x1000 /* LCD Frame Buffer Start Address register --------- */ + +#define SYSCON2 0x1100 /* System Control register 2 ----------------------- */ +#define SERSEL 0x00000001 /* 0 = Master/slave SSI2, 1 = Codec */ +#define KBD6 0x00000002 /* 1 = PADR[5:0] generates keyboard interrupts */ +#define DRAMSZ 0x00000004 /* 0 = 32-bit DRAM, 1 = 16-bit DRAM */ +#define KBWEN 0x00000008 /* enable keyboard wakeup */ +#define SS2TXEN 0x00000010 /* transmit enable for SSI2 */ +#define PCMCIA1 0x00000020 /* enable CL-PS6700 for PCMCIA slot 1 */ +#define PCMCIA2 0x00000040 /* enable CL-PS6700 for PCMCIA slot 2 */ +#define SS2RXEN 0x00000080 /* receive enable for SSI2 */ +#define UART2EN 0x00000100 /* enable UART2 */ +#define SS2MAEN 0x00000200 /* master mode enable for SSI2 */ +#define OSTB 0x00001000 /* operating system timing bit, for 13MHz mode */ +#define CLKENSL 0x00002000 /* select RUN/CLKEN signal: 0 = CLKEN, 1 = RUN */ +#define BUZFREQ 0x00004000 /* buzzer frequency: 0 = timer, 1 = 500Hz */ + +#define SYSFLG2 0x1140 /* System Status Flag register 2 ------------------- */ +#define SS2RXOF 0x00000001 /* SSI2 RX FIFO overflow */ +#define RESVAL 0x00000002 /* SSI2 RX FIFO residual byte, cleared by popping */ +#define RESFRM 0x00000004 /* SSI2 RX FIFO residual byte, cleared by frame */ +#define SS2RXFE 0x00000008 /* SSI2 RX FIFO empty */ +#define SS2TXFF 0x00000010 /* SSI2 TX FIFO full */ +#define SS2TXUF 0x00000020 /* SSI2 TX FIFO underflow */ +#define CKMODE 0x00000040 /* 0 = 18.432MHz PLL, 1 = 13MHz external clock */ +#define UBUSY2 0x00000800 /* UART2 transmitter busy */ +#define URXFE2 0x00400000 /* UART2 receiver FIFO empty */ +#define UTXFF2 0x00800000 /* UART2 transmit FIFO full */ + +#define INTSR2 0x1240 /* Interrupt Status register 2 --------------------- */ +#define KBDINT 0x00000001 /* keyboard interrupt */ +#define SS2RX 0x00000002 /* SSI2 receive FIFO half-full interrupt */ +#define SS2TX 0x00000004 /* SSI2 transmit FIFO half-empty interrupt */ +#define UTXINT2 0x00001000 /* UART2 transmit FIFO half-empty interrupt */ +#define URXINT2 0x00002000 /* UART2 receive FIFO half-full interrupt */ + +#define INTMR2 0x1280 /* Interrupt Mask register 2 ----------------------- */ +#define UARTDR2 0x1480 /* UART2 Data register ----------------------------- */ +#define UBRLCR2 0x14c0 /* UART2 Control register -------------------------- */ +#define SS2DR 0x1500 /* Master/slave SSI2 data register ----------------- */ +#define SRXEOF 0x1600 /* Write to clear RX FIFO overflow flag ------------ */ +#define SS2POP 0x16c0 /* Write to pop SSI2 residual byte into RX FIFO ---- */ +#define KBDEOI 0x1700 /* Write to clear keyboard interrupt --------------- */ + +#define MCCR 0x2000 /* MCP Control register ---------------------------- */ +#define MCDR0 0x2040 /* MCP Data register 0 ----------------------------- */ +#define MCDR1 0x2080 /* MCP Data register 1 ----------------------------- */ +#define MCDR2 0x20c0 /* MCP Data register 2 ----------------------------- */ +#define MCSR 0x2100 /* MCP Status register ----------------------------- */ + +#define SYSCON3 0x2200 /* System Control register 3 ----------------------- */ +#define ADCCON 0x00000001 /* ADC configuration */ +#define CLKCTL 0x00000006 /* processor clock control */ +#define CLKCTL_18 0x0 /* 18.432 MHz */ +#define CLKCTL_36 0x2 /* 36.864 MHz */ +#define CLKCTL_49 0x4 /* 49.152 MHz */ +#define CLKCTL_73 0x6 /* 73.728 MHz */ +#define MCPSEL 0x00000008 /* MCP select */ +#define ADCCKNSEN 0x000010 /* ADC clock sense */ +#define VERSN 0x000000e0 /* additional version bits */ +#define VERSN_SHIFT 5 +#define FASTWAKE 0x0000100 /* Wakeup clock select: 0=8Hz, 1=4kHz */ + +#define INTSR3 0x2240 /* Interrupt Status register 3 --------------------- */ +#define MCPINT 0x00000001 /* MCP interface interrupt (FIQ) */ + +#define INTMR3 0x2280 /* Interrupt Mask register 3 ----------------------- */ +#define LEDFLSH 0x22C0 /* LED Flash control register ---------------------- */ +#define LEDFLSH_RATE 0x03 /* flash rate */ +#define LEDFLSH_RATE_SHIFT 0 +#define LEDFLSH_DUTY 0x3c /* duty ratio */ +#define LEDFLSH_DUTY_SHIFT 2 +#define LEDFLSH_ENABLE 0x40 /* enable */ + +/* + * CS89712 PCMCIA memory constants + * + * Need to #define PCMCIA_BASE before using these macros. + */ + +#define PCMCIA_ATTR8(a) (PCMCIA_BASE+0x00000000+(a)) +#define PCMCIA_MEM(a) (PCMCIA_BASE+0x04000000+(a)) +#define PCMCIA_IO8(a) (PCMCIA_BASE+0x08000000+(a)) +#define PCMCIA_IO16(a) (PCMCIA_BASE+0x0c000000+((a) & ~3)+(((a) & 2) << 24)) + +#endif + + diff -urN hermit-1.3/include/cs89712/ioregs.h hermit/include/cs89712/ioregs.h --- hermit-1.3/include/cs89712/ioregs.h Wed Dec 31 17:00:00 1969 +++ hermit/include/cs89712/ioregs.h Tue Jul 10 13:24:36 2001 @@ -0,0 +1,78 @@ + +#ifndef _IOREGS_H_ +#define _IOREGS_H_ + +#include "cs89712.h" + +#define IO_START 0x80000000 + +#define IO(offset) (IO_START + (offset)) + +#define IO_BYTE(offset) (*(volatile unsigned char *)(IO_START + (offset))) +#define IO_WORD(offset) (*(volatile unsigned long *)(IO_START + (offset))) + +#define IO_PADR IO_BYTE(PADR) +#define IO_PBDR IO_BYTE(PBDR) +#define IO_PDDR IO_BYTE(PDDR) +#define IO_PADDR IO_BYTE(PADDR) +#define IO_PBDDR IO_BYTE(PBDDR) +#define IO_PDDDR IO_BYTE(PDDDR) +#define IO_PEDR IO_BYTE(PEDR) +#define IO_PEDDR IO_BYTE(PEDDR) +#define IO_SYSCON IO_WORD(SYSCON) +#define IO_SYSFLG IO_WORD(SYSFLG) +#define IO_MEMCFG1 IO_WORD(MEMCFG1) +#define IO_MEMCFG2 IO_WORD(MEMCFG2) +#define IO_DRFPR IO_WORD(DRFPR) +#define IO_INTSR IO_WORD(INTSR) +#define IO_INTMR IO_WORD(INTMR) +#define IO_LCDCON IO_WORD(LCDCON) +#define IO_TC1D IO_WORD(TC1D) +#define IO_TC2D IO_WORD(TC2D) +#define IO_RTCDR IO_WORD(RTCDR) +#define IO_RTCMR IO_WORD(RTCMR) +#define IO_PMPCON IO_WORD(PMPCON) +#define IO_CODR IO_BYTE(CODR) +#define IO_UARTDR IO_WORD(UARTDR) +#define IO_UBRLCR IO_WORD(UBRLCR) +#define IO_SYNCIO IO_WORD(SYNCIO) +#define IO_PALLSW IO_WORD(PALLSW) +#define IO_PALMSW IO_WORD(PALMSW) +#define IO_STFCLR IO_WORD(STFCLR) +#define IO_BLEOI IO_WORD(BLEOI) +#define IO_MCEOI IO_WORD(MCEOI) +#define IO_TEOI IO_WORD(TEOI) +#define IO_TC1EOI IO_WORD(TC1EOI) +#define IO_TC2EOI IO_WORD(TC2EOI) +#define IO_RTCEOI IO_WORD(RTCEOI) +#define IO_UMSEOI IO_WORD(UMSEOI) +#define IO_COEOI IO_WORD(COEOI) +#define IO_HALT IO_WORD(HALT) +#define IO_STDBY IO_WORD(STDBY) +#define IO_SYSCON1 IO_WORD(SYSCON1) +#define IO_SYSFLG1 IO_WORD(SYSFLG1) +#define IO_INTSR1 IO_WORD(INTSR1) +#define IO_INTMR1 IO_WORD(INTMR1) +#define IO_UARTDR1 IO_WORD(UARTDR1) +#define IO_UBRLCR1 IO_WORD(UBRLCR1) +#define IO_FRBADDR IO_WORD(FRBADDR) +#define IO_SYSCON2 IO_WORD(SYSCON2) +#define IO_SYSFLG2 IO_WORD(SYSFLG2) +#define IO_INTSR2 IO_WORD(INTSR2) +#define IO_INTMR2 IO_WORD(INTMR2) +#define IO_UARTDR2 IO_WORD(UARTDR2) +#define IO_UBRLCR2 IO_WORD(UBRLCR2) +#define IO_KBDEOI IO_WORD(KBDEOI) + +#define IO_MCCR IO_WORD(MCCR) +#define IO_MCDR0 IO_WORD(MCDR0) +#define IO_MCDR1 IO_WORD(MCDR1) +#define IO_MCDR2 IO_WORD(MCDR2) +#define IO_MCSR IO_WORD(MCSR) +#define IO_SYSCON3 IO_WORD(SYSCON3) +#define IO_INTSR3 IO_WORD(INTSR3) +#define IO_INTMR3 IO_WORD(INTMR3) +#define IO_LEDFLSH IO_WORD(LEDFLSH) + +#endif /* _IOREGS_H_ */ + diff -urN hermit-1.3/include/cs89712/memcpy.h hermit/include/cs89712/memcpy.h --- hermit-1.3/include/cs89712/memcpy.h Wed Dec 31 17:00:00 1969 +++ hermit/include/cs89712/memcpy.h Tue Jul 10 13:25:57 2001 @@ -0,0 +1,39 @@ +#ifndef _HERMIT_CS89712_MEMCPY_H_ +#define _HERMIT_CS89712_MEMCPY_H_ + +extern __inline__ void *memcpy(void *__dest, const void *__src, unsigned __n) +{ + int i = 0; + unsigned char *d = __dest; + unsigned const char *s = __src; + + for (i = __n >> 3; i > 0; i--) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + + if (__n & 1 << 2) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + + if (__n & 1 << 1) { + *d++ = *s++; + *d++ = *s++; + } + + if (__n & 1) + *d++ = *s++; + + return __dest; +} + +#endif /* _HERMIT_CS89712_MEMCPY_H_ */ diff -urN hermit-1.3/src/host/common/serial.c hermit/src/host/common/serial.c --- hermit-1.3/src/host/common/serial.c Mon Dec 18 19:35:49 2000 +++ hermit/src/host/common/serial.c Fri Jun 29 10:15:42 2001 @@ -51,9 +51,9 @@ newtios.c_cc[VMIN] = 1; /* block until 1 char received */ newtios.c_cc[VTIME] = 0; /* no inter-character timer */ - /* 9600 bps */ - cfsetospeed(&newtios, B9600); - cfsetispeed(&newtios, B9600); + /* 115200 bps */ + cfsetospeed(&newtios, B115200); + cfsetispeed(&newtios, B115200); /* register cleanup stuff */ atexit(reset_tty_atexit); diff -urN hermit-1.3/src/host/common/util.c hermit/src/host/common/util.c --- hermit-1.3/src/host/common/util.c Thu Mar 29 22:34:31 2001 +++ hermit/src/host/common/util.c Thu Jun 28 10:09:39 2001 @@ -11,7 +11,7 @@ #include "util.h" /* version string includes compile time and date for convenience */ -#define MAKE_VERSION(ver) "Hermit host-side v"##ver##" compiled "__TIME__##", "##__DATE__##" (CVS: $Id: util.c,v 1.24 2001/03/30 05:34:31 miket Exp $)"; +#define MAKE_VERSION(ver) "Hermit host-side v" #ver " compiled "__TIME__", "__DATE__" (CVS: $Id: util.c,v 1.24 2001/03/30 05:34:31 miket Exp $)"; static const char hermit_version[] = MAKE_VERSION("1.3"); diff -urN hermit-1.3/src/target/cs89712/Makefile hermit/src/target/cs89712/Makefile --- hermit-1.3/src/target/cs89712/Makefile Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/Makefile Tue Jul 10 15:06:49 2001 @@ -0,0 +1,131 @@ +# +# Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. +# + +# +# Guarantee that the top-level TARGET variable, if set, is cs89712. +# +ifeq (,$(TARGET)) + TARGET := cs89712 +endif +ifneq (cs89712,$(TARGET)) + error "building for cs89712 but TARGET != cs89712" +endif + +# +# Configure settings based on the target passed from the top-level +# makefile. The PROFILE := cdb89712 line is just a default and can +# be overridden from the command line. +# +PROFILE := cdb89712 + +ifneq (,$(wildcard profile-stamp)) + last-profile := $(shell cat profile-stamp) + ifneq ($(PROFILE),$(last-profile)) + error := profile-error + endif +endif + +ifeq ($(PROFILE),cdb89712) + SETTINGS := relocate standalone +endif +ifeq ($(PROFILE),cdb89712-boot) + SETTINGS := bootmode standalone +endif +ifeq ($(PROFILE),cdb89712-kernel) + SETTINGS := kernel standalone +endif + +# +# Configuration for standalone, optimized ARM7TDMI cross-compile. +# +CROSS := arm-linux- +CC := $(CROSS)gcc +CFLAGS := -Wall -O2 -fomit-frame-pointer -I../../../include -nostdlib \ + -mcpu=arm7tdmi -static + +# +# The LDSCRIPT variable can be overridden based on the target-derived +# settings. +# +LDSCRIPT := flash +OBJSECTIONS := .boot .text .data .bss +OBJCOPYFLAGS := -O binary -S $(addprefix -j ,$(OBJSECTIONS)) + +ASMS := boot.S +SRCS := entry.c eth.c flash_intel.c frob.c gunzip.c \ + linux.c loader.c medium.c memmap.c memzero.c + +setp = $(if $(findstring $(1),$(SETTINGS)),y) + +ifeq (y,$(call setp,bootmode)) + ASMS := init.S + CFLAGS += -DBOOTMODE + LDSCRIPT := bootmode +endif + +ifeq (y,$(call setp,kernel)) + ASMS := init.S + LDSCRIPT := kernel +endif + +ifeq (y,$(call setp,relocate)) + CFLAGS += -DRELOCATE +endif + +ifeq (y,$(call setp,standalone)) + CFLAGS += -DSTANDALONE +endif + +OBJS := $(SRCS:.c=.o) +DEPS := $(SRCS:.c=.d) +LIBS := -lgcc -ltarget + +all: $(error) profile-stamp loader-$(PROFILE).bin + +profile-error: + @echo "previous PROFILE:" `cat profile-stamp` + @echo "profile-stamp mismatch; 'make scrub' to switch profiles"; false +profile-stamp: + echo $(PROFILE) > $@ + +# can be invoked from top-level Makefile +download: + shoehorn --terminal + +# Hermit second stage loader (ELF image) +loader-$(PROFILE).elf: $(ASMS) $(OBJS) ../common/libtarget.a Makefile loader-$(PROFILE).lds + $(CC) $(CFLAGS) -L. -L../common \ + -Wl,-Map,loader-$(PROFILE).map \ + -Wl,-Tloader-$(PROFILE).lds -o $@ \ + $(ASMS) $(OBJS) \ + -Wl,--start-group $(LIBS) -Wl,--end-group + +loader-$(PROFILE).lds: $(wildcard loader.lds.*) + cp loader.lds.$(LDSCRIPT) $@ + +%.bin: %.elf + $(CROSS)objcopy $(OBJCOPYFLAGS) $< $@ + +# automated dependency checking +ifeq (,$(filter clean scrub,$(MAKECMDGOALS))) +include $(DEPS) + +DEPENDS := ../../../depend.sh +%.d: %.c + env CC=$(CC) $(DEPENDS) $< $@ $(CFLAGS) +endif + +# installation +PHONY: install +install: + $(INSTALL) -m 644 -o root -g root loader-$(PROFILE).bin \ + $(INSTALLPREFIX)/lib/hermit/ + +# housecleaning +.PHONY: clean +clean: + rm -f $(OBJS) loader-*.lds *.elf *.bin *.map +scrub: clean + rm -f profile-stamp *.d + diff -urN hermit-1.3/src/target/cs89712/boot.S hermit/src/target/cs89712/boot.S --- hermit-1.3/src/target/cs89712/boot.S Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/boot.S Tue Jul 10 15:02:56 2001 @@ -0,0 +1,59 @@ +/* + * boot.S: assembly language bootstrap + * + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include "memregions.h" + + .section .flash.boot + .global _start_flash +_start_flash: + mov r0, #0x70 /* 32-bit code + data, MMU mandatory */ + mcr p15, 0, r0, c1, c0, 0 /* MMU init */ + + mov r0, #0 + mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ + mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ + + mov r0, #0x80000000 /* I/O base */ + + mov r1, #0x100 /* UART enable bit in SYSCON[1|2] */ + str r1, [r0, #0x100] /* enable UART1 in SYSCON1 */ + add r2, r0, #0x1100 /* load address of SYSCON2 in r2 */ + str r1, [r2] /* enable UART2 in SYSCON2 */ + + mov r1, #0x00060000 /* UART 8-bit data length */ + orr r1, r1, #1 /* UART 115200 bps */ + str r1, [r0, #0x4C0] /* set UART1 bit rate/line control */ + add r2, r0, #0x14C0 /* load address of UBRLCR2 in r2 */ + str r1, [r2] /* set UART2 bit rate/line control */ + + mov r1, #0x6 /* CLKCTL_73 in SYSCON3 */ + add r2, r0, #0x2200 /* address of SYSCON3 in r2 */ + str r1, [r2] /* set clock speed to 73.728 MHz */ + + mov r1, #0x81 /* 64KHz DRAM refresh period */ + str r1, [r0, #0x200] /* set DRFPR */ + + mov r1, #0x500 /* CAS lat = 2, permanent enable, 16 bit wide, 64Mbit SDRAM */ + add r1, r1, #0x22 + add r2, r0, #0x2300 /* load address in r2 */ + str r1, [r2] + + mov r1, #0x100 /* SDRAM refresh rate */ + add r2, r0, #0x2340 /* load address in r2 */ + str r1, [r2] + + mov sp, #SRAM_START /* init stack pointer */ + add sp, sp, #SRAM_SIZE + + bl entry /* see entry.c */ +1: b 1b + + .section .ram.boot + .global _start_ram +_start_ram: + bl main +2: b 2b + diff -urN hermit-1.3/src/target/cs89712/cs8900.h hermit/src/target/cs89712/cs8900.h --- hermit-1.3/src/target/cs89712/cs8900.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/cs8900.h Tue Jul 10 13:40:43 2001 @@ -0,0 +1,204 @@ +/* Cirrus Logic CS8900A Ethernet */ + +#include "memmap.h" + +#define CS8900_RTDATA *(volatile unsigned int *)(EXT_CS8900_BASE+0x00) +#define CS8900_TxCMD *(volatile unsigned short *)(EXT_CS8900_BASE+0x04) +#define CS8900_TxLEN *(volatile unsigned short *)(EXT_CS8900_BASE+0x06) +#define CS8900_ISQ *(volatile unsigned short *)(EXT_CS8900_BASE+0x08) +#define CS8900_PPTR *(volatile unsigned short *)(EXT_CS8900_BASE+0x0a) +#define CS8900_PDATA *(volatile unsigned int *)(EXT_CS8900_BASE+0x0c) + +#define ISQ_RxEvent 0x04 +#define ISQ_TxEvent 0x08 +#define ISQ_BufEvent 0x0C +#define ISQ_RxMissEvent 0x10 +#define ISQ_TxColEvent 0x12 +#define ISQ_EventMask 0x3F + +/* packet page register offsets */ + +/* bus interface registers */ +#define PP_ChipID 0x0000 // Chip identifier - must be 0x630E +#define PP_ChipRev 0x0002 // Chip revision, model codes + +#define PP_IntReg 0x0022 // Interrupt configuration +#define PP_IntReg_IRQ0 0x0000 // Use INTR0 pin +#define PP_IntReg_IRQ1 0x0001 // Use INTR1 pin +#define PP_IntReg_IRQ2 0x0002 // Use INTR2 pin +#define PP_IntReg_IRQ3 0x0003 // Use INTR3 pin + +/* status and control registers */ + +#define PP_RxCFG 0x0102 // Receiver configuration +#define PP_RxCFG_Skip1 0x0040 // Skip (i.e. discard) current frame +#define PP_RxCFG_Stream 0x0080 // Enable streaming mode +#define PP_RxCFG_RxOK 0x0100 // RxOK interrupt enable +#define PP_RxCFG_RxDMAonly 0x0200 // Use RxDMA for all frames +#define PP_RxCFG_AutoRxDMA 0x0400 // Select RxDMA automatically +#define PP_RxCFG_BufferCRC 0x0800 // Include CRC characters in frame +#define PP_RxCFG_CRC 0x1000 // Enable interrupt on CRC error +#define PP_RxCFG_RUNT 0x2000 // Enable interrupt on RUNT frames +#define PP_RxCFG_EXTRA 0x4000 // Enable interrupt on frames with extra data + +#define PP_RxCTL 0x0104 // Receiver control +#define PP_RxCTL_IAHash 0x0040 // Accept frames that match hash +#define PP_RxCTL_Promiscuous 0x0080 // Accept any frame +#define PP_RxCTL_RxOK 0x0100 // Accept well formed frames +#define PP_RxCTL_Multicast 0x0200 // Accept multicast frames +#define PP_RxCTL_IA 0x0400 // Accept frame that matches IA +#define PP_RxCTL_Broadcast 0x0800 // Accept broadcast frames +#define PP_RxCTL_CRC 0x1000 // Accept frames with bad CRC +#define PP_RxCTL_RUNT 0x2000 // Accept runt frames +#define PP_RxCTL_EXTRA 0x4000 // Accept frames that are too long + +#define PP_TxCFG 0x0106 // Transmit configuration +#define PP_TxCFG_CRS 0x0040 // Enable interrupt on loss of carrier +#define PP_TxCFG_SQE 0x0080 // Enable interrupt on Signal Quality Error +#define PP_TxCFG_TxOK 0x0100 // Enable interrupt on successful xmits +#define PP_TxCFG_Late 0x0200 // Enable interrupt on "out of window" +#define PP_TxCFG_Jabber 0x0400 // Enable interrupt on jabber detect +#define PP_TxCFG_Collision 0x0800 // Enable interrupt if collision +#define PP_TxCFG_16Collisions 0x8000 // Enable interrupt if > 16 collisions + +#define PP_TxCmd 0x0108 // Transmit command status +#define PP_TxCmd_TxStart_5 0x0000 // Start after 5 bytes in buffer +#define PP_TxCmd_TxStart_381 0x0040 // Start after 381 bytes in buffer +#define PP_TxCmd_TxStart_1021 0x0080 // Start after 1021 bytes in buffer +#define PP_TxCmd_TxStart_Full 0x00C0 // Start after all bytes loaded +#define PP_TxCmd_Force 0x0100 // Discard any pending packets +#define PP_TxCmd_OneCollision 0x0200 // Abort after a single collision +#define PP_TxCmd_NoCRC 0x1000 // Do not add CRC +#define PP_TxCmd_NoPad 0x2000 // Do not pad short packets + +#define PP_BufCFG 0x010A // Buffer configuration +#define PP_BufCFG_SWI 0x0040 // Force interrupt via software +#define PP_BufCFG_RxDMA 0x0080 // Enable interrupt on Rx DMA +#define PP_BufCFG_TxRDY 0x0100 // Enable interrupt when ready for Tx +#define PP_BufCFG_TxUE 0x0200 // Enable interrupt in Tx underrun +#define PP_BufCFG_RxMiss 0x0400 // Enable interrupt on missed Rx packets +#define PP_BufCFG_Rx128 0x0800 // Enable Rx interrupt after 128 bytes +#define PP_BufCFG_TxCol 0x1000 // Enable int on Tx collision ctr overflow +#define PP_BufCFG_Miss 0x2000 // Enable int on Rx miss ctr overflow +#define PP_BufCFG_RxDest 0x8000 // Enable int on Rx dest addr match + +#define PP_LineCTL 0x0112 // Line control +#define PP_LineCTL_Rx 0x0040 // Enable receiver +#define PP_LineCTL_Tx 0x0080 // Enable transmitter +#define PP_LineCTL_AUIonly 0x0100 // AUI interface only +#define PP_LineCTL_AutoAUI10BT 0x0200 // Autodetect AUI or 10BaseT interface +#define PP_LineCTL_ModBackoffE 0x0800 // Enable modified backoff algorithm +#define PP_LineCTL_PolarityDis 0x1000 // Disable Rx polarity autodetect +#define PP_LineCTL_2partDefDis 0x2000 // Disable two-part defferal +#define PP_LineCTL_LoRxSquelch 0x4000 // Reduce receiver squelch threshold + +#define PP_SelfCTL 0x0114 // Chip self control +#define PP_SelfCTL_Reset 0x0040 // Self-clearing reset +#define PP_SelfCTL_SWSuspend 0x0100 // Initiate suspend mode +#define PP_SelfCTL_HWSleepE 0x0200 // Enable SLEEP input +#define PP_SelfCTL_HWStandbyE 0x0400 // Enable standby mode +#define PP_SelfCTL_HC0E 0x1000 // use HCB0 for LINK LED +#define PP_SelfCTL_HC1E 0x2000 // use HCB1 for BSTATUS LED +#define PP_SelfCTL_HCB0 0x4000 // control LINK LED if HC0E set +#define PP_SelfCTL_HCB1 0x8000 // control BSTATUS LED if HC1E set + +#define PP_BusCTL 0x0116 // Bus control +#define PP_BusCTL_ResetRxDMA 0x0040 // Reset RxDMA pointer +#define PP_BusCTL_DMAextend 0x0100 // Extend DMA cycle +#define PP_BusCTL_UseSA 0x0200 // Assert MEMCS16 on address decode +#define PP_BusCTL_MemoryE 0x0400 // Enable memory mode +#define PP_BusCTL_DMAburst 0x0800 // Limit DMA access burst +#define PP_BusCTL_IOCHRDYE 0x1000 // Set IOCHRDY high impedence +#define PP_BusCTL_RxDMAsize 0x2000 // Set DMA buffer size 64KB +#define PP_BusCTL_EnableIRQ 0x8000 // Generate interrupt on interrupt event + +#define PP_TestCTL 0x0118 // Test control +#define PP_TestCTL_DisableLT 0x0080 // Disable link status +#define PP_TestCTL_ENDECloop 0x0200 // Internal loopback +#define PP_TestCTL_AUIloop 0x0400 // AUI loopback +#define PP_TestCTL_DisBackoff 0x0800 // Disable backoff algorithm +#define PP_TestCTL_FDX 0x4000 // Enable full duplex mode + +#define PP_ISQ 0x0120 // Interrupt Status Queue + +#define PP_RER 0x0124 // Receive event +#define PP_RER_IAHash 0x0040 // Frame hash match +#define PP_RER_Dribble 0x0080 // Frame had 1-7 extra bits after last byte +#define PP_RER_RxOK 0x0100 // Frame received with no errors +#define PP_RER_Hashed 0x0200 // Frame address hashed OK +#define PP_RER_IA 0x0400 // Frame address matched IA +#define PP_RER_Broadcast 0x0800 // Broadcast frame +#define PP_RER_CRC 0x1000 // Frame had CRC error +#define PP_RER_RUNT 0x2000 // Runt frame +#define PP_RER_EXTRA 0x4000 // Frame was too long + +#define PP_TER 0x0128 // Transmit event +#define PP_TER_CRS 0x0040 // Carrier lost +#define PP_TER_SQE 0x0080 // Signal Quality Error +#define PP_TER_TxOK 0x0100 // Packet sent without error +#define PP_TER_Late 0x0200 // Out of window +#define PP_TER_Jabber 0x0400 // Stuck transmit? +#define PP_TER_NumCollisions 0x7800 // Number of collisions +#define PP_TER_16Collisions 0x8000 // > 16 collisions + +#define PP_BER 0x012C // Buffer event +#define PP_BER_SWint 0x0040 // Software interrupt +#define PP_BER_RxDMAFrame 0x0080 // Received framed DMAed +#define PP_BER_Rdy4Tx 0x0100 // Ready for transmission +#define PP_BER_TxUnderrun 0x0200 // Transmit underrun +#define PP_BER_RxMiss 0x0400 // Received frame missed +#define PP_BER_Rx128 0x0800 // 128 bytes received +#define PP_BER_RxDest 0x8000 // Received framed passed address filter + +#define PP_RxMiss 0x0130 // Receiver miss counter + +#define PP_TxCol 0x0132 // Transmit collision counter + +#define PP_LineSTAT 0x0134 // Line status +#define PP_LineSTAT_LinkOK 0x0080 // Line is connected and working +#define PP_LineSTAT_AUI 0x0100 // Connected via AUI +#define PP_LineSTAT_10BT 0x0200 // Connected via twisted pair +#define PP_LineSTAT_Polarity 0x1000 // Line polarity OK (10BT only) +#define PP_LineSTAT_CRS 0x4000 // Frame being received + +#define PP_SelfSTAT 0x0136 // Chip self status +#define PP_SelfSTAT_33VActive 0x0040 // supply voltage is 3.3V +#define PP_SelfSTAT_InitD 0x0080 // Chip initialization complete +#define PP_SelfSTAT_SIBSY 0x0100 // EEPROM is busy +#define PP_SelfSTAT_EEPROM 0x0200 // EEPROM present +#define PP_SelfSTAT_EEPROM_OK 0x0400 // EEPROM checks out +#define PP_SelfSTAT_ELPresent 0x0800 // External address latch logic available +#define PP_SelfSTAT_EEsize 0x1000 // Size of EEPROM + +#define PP_BusSTAT 0x0138 // Bus status +#define PP_BusSTAT_TxBid 0x0080 // Tx error +#define PP_BusSTAT_TxRDY 0x0100 // Ready for Tx data + +#define PP_TDR 0x013C // AUI Time Domain Reflectometer + +/* initiate transmit registers */ + +#define PP_TxCommand 0x0144 // Tx Command +#define PP_TxLength 0x0146 // Tx Length + + +/* address filter registers */ + +#define PP_LAF 0x0150 // Logical address filter (6 bytes) +#define PP_IA 0x0158 // Individual address (MAC) + +/* packet page register access functions */ + +static __inline__ unsigned short +get_reg(int regno) +{ + CS8900_PPTR = regno; + return (unsigned short) CS8900_PDATA; +} + +static __inline__ void +put_reg(int regno, unsigned short val) +{ + CS8900_PPTR = regno; + CS8900_PDATA = val; +} diff -urN hermit-1.3/src/target/cs89712/entry.c hermit/src/target/cs89712/entry.c --- hermit-1.3/src/target/cs89712/entry.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/entry.c Tue Jul 10 16:35:33 2001 @@ -0,0 +1,92 @@ +/* + * Initial C entry point of the boot loader. Called by the assembly + * language setup code in boot.S/init.S. + * + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + * + * We must have a stack pointer, but there are no other preconditions. + * + * The generated text for this file lives in the .hermit.boot section + * of the loader executable. Symbols in the .hermit.boot section have + * relocation addresses equal to their load addresses (see the link + * map for details), so this section is designed to run from flash at + * boot time. In GNU linker terminology, these symbols have VMA == + * LMA ('info ld' for definitions). + * + * Pretty much all other symbols in the loader have VMAs within SRAM + * or DRAM (depending on build configuration). This means that their + * load addresses (LMAs) are not equal to their VMAs. Ergo most of + * the loader must be relocated to RAM before it can run; we even + * relocate the text segment to RAM, to make it possible to reprogram + * the loader in flash. This file handles the relocation. + * + * Until the relocation is done, the loader won't be able to access + * any writeable data (.data segment stuff) or use zeroed global + * memory (.bss). Be careful when editing the code here! + * + * --miket + */ + +extern unsigned char __bss_start; +extern unsigned char __bss_end; + +#ifdef RELOCATE + +#include + +/* see loader.lds */ +extern unsigned char __text_start_flash; +extern unsigned char __text_start; +extern unsigned char __text_end; +extern unsigned char __data_start_flash; +extern unsigned char __data_start; +extern unsigned char __data_end; + +void entry(void) +{ + unsigned char *src, *dst; + + /* relocate .text */ + src = &__text_start_flash; + dst = &__text_start; + while (dst < &__text_end) + *dst++ = *src++; + + /* relocate .data */ + src = &__data_start_flash; + dst = &__data_start; + while (dst < &__data_end) + *dst++ = *src++; + + /* clear .bss */ + dst = &__bss_start; + while (dst < &__bss_end) + *dst++ = 0; + + /* branch into relocated code */ + __asm__ volatile ( + " mov r0, #0x60000000\n" /* start of SRAM */ + " mov pc, r0" /* go there */ + ); +} + +#else + +/* see loader.c */ +extern void main(void); + +void entry(void) +{ + unsigned char *dst; + + /* clear .bss */ + dst = &__bss_start; + while (dst < &__bss_end) + *dst++ = 0; + + main(); +} + +#endif + + diff -urN hermit-1.3/src/target/cs89712/eth.c hermit/src/target/cs89712/eth.c --- hermit-1.3/src/target/cs89712/eth.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/eth.c Tue Jul 10 13:17:40 2001 @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "cs8900.h" +#include "eth.h" + +int ether_init(void) +{ + volatile int i; + + /* check chip ID */ + if (0 && get_reg(PP_ChipID) != 0x630e) { + errdata.msg = "CS8900 chip ID mismatch"; + return -H_ECUSTOM; + } + + /* reset */ + put_reg(PP_SelfCTL, PP_SelfCTL_Reset); + for (i=100000; i; --i) /* nada */; /* XXX should be 10ms */ + while ((get_reg(PP_SelfSTAT) & PP_SelfSTAT_InitD) == 0); + + /* enable receiver mode */ + put_reg(PP_RxCFG, PP_RxCFG_RxOK); + put_reg(PP_RxCTL, PP_RxCTL_RxOK | PP_RxCTL_IA); + put_reg(PP_LineCTL, PP_LineCTL_Rx); + + return 0; +} + +static int ether_mac_cmdfunc(int argc, char *argv[]) +{ + unsigned char macaddr [6]; + char *p; + word_t word; + int i; + + i = ether_init(); + if (i < 0) + return i; + if (argc == 1) { + /* print current MAC address */ + for (i=0; i<6; i+=2) { + unsigned short sh = get_reg(PP_IA+i); + hprintf("%b:%b%c", sh & 0xff, sh >> 8, + (i < 4) ? ':' : '\n'); + } + return 0; + } + if (argc != 2) + return -H_EUSAGE; + + /* parse given MAC address */ + p = *++argv; + for (i = 0; *p && (i < 6); i++) { + scan_hex(p, &word); + macaddr[i] = (unsigned char) word; + while (*p && (*p != ':')) + ++p; + ++p; /* increment past colon */ + } + if (i < 6) + return -H_EUSAGE; + + /* write address to Ethernet controller */ + for (i = 0; i < 6; i += 2) { + unsigned short sh = + (((unsigned short) macaddr[i+1]) << 8) | + macaddr[i]; + put_reg(PP_IA+i, sh); + } + return 0; +} + +const command_t ether_mac_command = + { "mac", "[]", "get/set Ethernet MAC address", + ðer_mac_cmdfunc }; + +int ether_read(unsigned char *buf, int bufsize) +{ + unsigned short i, rxlen; + int length; + + /* wait for data */ + while (!(get_reg(PP_RER) & PP_RER_RxOK)); + + CS8900_RTDATA; /* stat */ + rxlen = CS8900_RTDATA; /* len */ + + /* 14 bytes for dst, src, and type; 6 for our header */ + assert(rxlen > 20); + + /* read and discard ethernet frame header */ + for (i=0; i<7; i++) + CS8900_RTDATA; + rxlen -= 14; + + /* byte swap next 2 bytes to get length */ + i = CS8900_RTDATA; + rxlen -= 2; + i = (i << 8) | (i >> 8); + length = (unsigned) i; + + /* read and discard sequence number (should use for assertions) */ + CS8900_RTDATA; + CS8900_RTDATA; + rxlen -= 4; + + /* read entire frame; store 'bufsize' bytes only */ + for (i=0; i 0) + *buf++ = w & 0xff; + if (bufsize-- > 0) + *buf++ = w >> 8; + } + + /* ack current packet */ + hputchar('K'); + return length; +} + diff -urN hermit-1.3/src/target/cs89712/eth.h hermit/src/target/cs89712/eth.h --- hermit-1.3/src/target/cs89712/eth.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/eth.h Tue Jul 10 13:17:40 2001 @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_TARGET_ETH_H +#define _HERMIT_TARGET_ETH_H + +#include + +extern int ether_init(void); +extern int ether_read(unsigned char *buf, int bufsize); + +extern const command_t ether_mac_command; + +#endif /* _HERMIT_TARGET_ETH_H */ diff -urN hermit-1.3/src/target/cs89712/flash.h hermit/src/target/cs89712/flash.h --- hermit-1.3/src/target/cs89712/flash.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/flash.h Tue Jul 10 13:17:40 2001 @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_TARGET_FLASH_H_ +#define _HERMIT_TARGET_FLASH_H_ + +#include + +extern const command_t flash_erase_command; +extern const command_t flash_program_command; + +#endif /* _HERMIT_TARGET_FLASH_H_ */ diff -urN hermit-1.3/src/target/cs89712/flash_intel.c hermit/src/target/cs89712/flash_intel.c --- hermit-1.3/src/target/cs89712/flash_intel.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/flash_intel.c Tue Jul 10 15:15:38 2001 @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + * + * Commands to program the Intel 28F320B3 flash chips on the Cirrus + * Logic CDB89712 evaluation board. These are 32 Mbit "bottom boot" + * (boot and param blocks at low end of address space) flash chips. + * + * The CDB89712 has two 8Mbyte flash banks, each using two flash chips. + * The flash chips are 16 bits wide; one occupies the 16 high lines on + * the data bus, the other the low lines. So when we write commands + * to the flash, we have to duplicate each command across each half of + * the data bus: + * + * *addr = 0x00FF00FF; + * + * This is seen as a word-wide write of 0x00FF by each 16-bit flash + * chip. Such an arrangement should be familiar to embedded + * developers who have worked with flash in 32-bit systems. + * + * Two of the boot blocks in each flash are write protected. We don't + * provide any way of circumventing that protection here. From a + * quick look at the CDB89712 schematics, it looks like the write + * protect line is held at logic high, so the blocks are always + * writeable on this board. + * + * Even in other configurations (e.g. WP line wired to a GPIO output) + * I expect that I'll want to avoid automatic disabling of write + * protect here, since the consequences of writing garbage into the + * boot blocks can be grave. In the infrequent case in which you're + * writing over the boot loader itself, it's not too onerous to have + * to fire up the command line and do a little register prodding. + */ + +#include +#include +#include +#include + +#include "flash.h" + +/* download buffer for the flash programmer */ +#define DLBUFSIZE (8*1024) +unsigned char dlbuf [DLBUFSIZE]; +word_t dlbufsize = DLBUFSIZE; + +/* timeout for auto-boot, in seconds */ +#define FL_WORD(addr) (*(volatile unsigned long*)(addr)) + +/* command user interface (CUI) */ +#define CUI_READ_ARRAY 0x00FF00FF; +#define CUI_READ_IDENTIFIER 0x00900090; +#define CUI_READ_STATUS 0x00700070; +#define CUI_CLEAR_STATUS 0x00500050; +#define CUI_PROGRAM 0x00400040; +#define CUI_BLOCK_ERASE 0x00200020; +#define CUI_PROG_ERASE_SUSPEND 0x00B000B0; +#define CUI_PROG_ERASE_RESUME 0x00D000D0; + +/* status register bits */ +#define SR7_WSMS (1<<7) /* Write State Machine Status */ +#define SR6_ESS (1<<6) /* Erase-Suspend Status */ +#define SR5_ES (1<<5) /* Erase Status */ +#define SR4_PS (1<<4) /* Program Status */ +#define SR3_VPPS (1<<3) /* V_PP (program voltage) Status */ +#define SR2_PSS (1<<2) /* Program Suspend Status */ +#define SR1_BLLK (1<<1) /* Block Lock Status */ +/* bit 0 is reserved */ + +#define SR_MASK (SR7_WSMS|SR6_ESS|SR5_ES|SR4_PS|SR3_VPPS|SR2_PSS|SR1_BLLK) +#define SR_ERASE_ERR (SR5_ES|SR4_PS|SR3_VPPS|SR1_BLLK) +#define SR_BOTH_MASK (SM_MASK | (SM_MASK << 16)) +#define SR_BOTH_WSMS (SR7_WSMS | (SR7_WSMS << 16)) +#define SR_BOTH_ERASE_ERR (SR_ERASE_ERR | (SR_ERASE_ERR << 16)) + +/* handy flash functions */ +static void flash_print_chip_error_string(unsigned char status); +static void flash_print_error_string(void); +static word_t flash_status_wait(addr_t addr); +static int flash_status_full_check(addr_t addr); + +static void flash_print_chip_error_string(unsigned char status) +{ + if (status & SR3_VPPS) + hprint("VPPRange"); + else if ((status & SR5_ES) && (status & SR4_PS)) + hprint("CommandSequence"); + else if (status & SR5_ES) + hprint("BlockErase"); + else if (status & SR1_BLLK) + hprint("LockedBlock"); + else + hprint("NoError"); +} + +/* + * Come up with an error string representing the flash error; we can + * have distinct errors for the two chips. Get the status from + * errdata, since this is used for error output. + */ +static void flash_print_error_string(void) +{ + hprint("lowbank:"); + flash_print_chip_error_string(errdata.word & SR_MASK); + hprint(" highbank:"); + flash_print_chip_error_string((errdata.word >> 16) & SR_MASK); +} + +/* + * Loop until both write state machines complete. + */ +static word_t flash_status_wait(addr_t addr) +{ + word_t status; + do { + status = FL_WORD(addr); + } while ((status & SR_BOTH_WSMS) != SR_BOTH_WSMS); + return status; +} + +/* + * Loop until the Write State machine is ready, then do a full error + * check. Clear status and leave the flash in Read Array mode; return + * 0 for no error, -1 for error. + */ +static int flash_status_full_check(addr_t addr) +{ + word_t status; + + status = flash_status_wait(addr) & SR_BOTH_ERASE_ERR; + if (status) { + errdata.word = status; + errfunc = &flash_print_error_string; + } + FL_WORD(addr) = CUI_CLEAR_STATUS; + FL_WORD(addr) = CUI_READ_ARRAY; + return status ? -1 : 0; +} + +/* + * Program the contents of the download buffer to flash at the given + * address. Size is also specified; we shouldn't have to track usage + * of the download buffer, since the host side can easily do that. + * + * We write words without checking status between each; we only go + * through the full status check procedure once, when the full buffer + * has been written. + * + * Alignment problems are errors here; we don't automatically correct + * them because in the context of this command they signify bugs, and + * we want to be extra careful when writing flash. + */ +static int flash_program_cmdfunc(int argc, char *argv[]) +{ + addr_t addr; + size_t size; + word_t *ptr; + + if (argc != 3) + return -H_EUSAGE; + if (scan(*++argv, &addr)) return -H_EADDR; + if (scan(*++argv, &size)) return -H_EADDR; + if (addr & UNALIGNED_MASK) return -H_EALIGN; + if (size & UNALIGNED_MASK) return -H_EALIGN; + + size >>= BYTE_TO_WORD_SHIFT; + for (ptr = (word_t*)dlbuf; size--; addr += sizeof(word_t)) { + FL_WORD(addr) = CUI_PROGRAM; + FL_WORD(addr) = *ptr++; + flash_status_wait(addr); + } + return flash_status_full_check(addr); +} + +const command_t flash_program_command = + { "program", " ", + "program flash from download buffer", + &flash_program_cmdfunc }; + +/* + * Erase a flash block. Single argument is the first address in the + * block (actually, it can be anywhere in the block, but the host-side + * hermit downloader gives the first address). + */ +static int flash_erase_cmdfunc(int argc, char *argv[]) +{ + addr_t addr; + + if (argc != 2) + return -H_EUSAGE; + if (scan(*++argv, &addr)) return -H_EADDR; + addr &= ~(addr_t)UNALIGNED_MASK; /* word align */ + + FL_WORD(addr) = CUI_BLOCK_ERASE; + FL_WORD(addr) = CUI_PROG_ERASE_RESUME; + return flash_status_full_check(addr); +} + +const command_t flash_erase_command = + { "erase", "", "erase flash block", &flash_erase_cmdfunc }; diff -urN hermit-1.3/src/target/cs89712/frob.c hermit/src/target/cs89712/frob.c --- hermit-1.3/src/target/cs89712/frob.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/frob.c Tue Jul 10 13:48:20 2001 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include "frob.h" + +static const command_t *frob_commands[] = { + &help_command, + &peek_command, + &peek8_command, + &peek16_command, + &peeknext_command, + &poke_command, + &poke8_command, + &poke16_command, + &quit_command, + 0 +}; + +ABBR(help_command, '?') +ABBR(peek_command, 'p') +ABBR(peek8_command, '8') +ABBR(peeknext_command, 'n') +ABBR(poke_command, 'k') +ABBR(quit_command, 'q') + +static const abbrev_t *frob_abbrevs[] = { + &help_command_abbrev, + &peek_command_abbrev, + &peek8_command_abbrev, + &peeknext_command_abbrev, + &poke_command_abbrev, + &quit_command_abbrev, + 0 +}; + +static command_list_t frob_command_list = + { frob_commands, frob_abbrevs, "frob", 0 }; + +static int frob_cmdfunc(int argc, char *argv[]) +{ + do_command_loop(&frob_command_list); + return 0; +} + +const command_t frob_command = + { "frob", 0, "commands for frobbing memory", &frob_cmdfunc }; + diff -urN hermit-1.3/src/target/cs89712/frob.h hermit/src/target/cs89712/frob.h --- hermit-1.3/src/target/cs89712/frob.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/frob.h Tue Jul 10 13:46:18 2001 @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_CDB89712_FROB_H_ +#define _HERMIT_CDB89712_FROB_H_ + +#include + +extern const command_t frob_command; + +#endif /* _HERMIT_CDB89712_FROB_H_ */ diff -urN hermit-1.3/src/target/cs89712/gunzip.c hermit/src/target/cs89712/gunzip.c --- hermit-1.3/src/target/cs89712/gunzip.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/gunzip.c Tue Jul 10 18:35:28 2001 @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include +#include + +#include "gunzip.h" +#include "memmap.h" +#include "memzero.h" +#include "linux.h" + +/* declarations for Linux kernel gzip */ +#define NULL ((void*) 0) +#define OF(args) args +#define STATIC static + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +/* sliding window size; must be at least 32K, and a power of two */ +#define WSIZE 0x8000 + +/* diagnostic functions; not used here */ +#ifdef DEBUG_GUNZIP +# define Assert(cond,msg) {if(!(cond)) error(msg);} +# define Trace(x) fprintf x +# define Tracev(x) {if (verbose) fprintf x ;} +# define Tracevv(x) {if (verbose>1) fprintf x ;} +# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} +# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +/* variables accessed/referenced by inflate.c code */ +static uch *window; /* sliding window buffer */ +static unsigned outcnt; /* bytes in output buffer */ +static ulg bytes_out; /* total bytes output */ + +/* support functions for inflate.c code */ +static void flush_window(void); +static void free(void *where); +#define STRING_ERRORS +#ifdef STRING_ERRORS +static void error(const char *message); +#else +#define error(m) +#endif +static void gzip_mark(void **); +static void gzip_release(void **); +static void *malloc(int size); + +static uch *hermit_input_ptr; /* address of next input byte */ +extern __inline__ uch get_byte(void) { return *hermit_input_ptr++; } +extern __inline__ void put_byte(void) { --hermit_input_ptr; } + +/* include gunzip implementation from Linux kernel */ +#include + +/* variables not used by inflate.c */ +#define HERMIT_HEAP_SIZE 0x2000 /* size of heap for mini-allocator */ +static ulg hermit_free_mem_ptr; /* used by mini-allocator below */ +static ulg hermit_free_mem_ptr_end; /* likewise */ +static uch *hermit_output_ptr; /* decompress destination */ +static int hermit_progress; /* < 0 for no progress output; + otherwise keeps track of # of + times the decompression window + has been flushed */ + +/* for progress boxes */ +extern __inline__ void progress(void) { } + +#ifdef STRING_ERRORS +static void error(const char *message) +{ + hprintf("\n\nERROR: %s\n\n -- System halted\n", message); + while (1); +} +#endif + +/* write the contents of the decompression window to output */ +static void flush_window(void) +{ + uch *in = window; + for (bytes_out += outcnt; outcnt; --outcnt) { + uch ch = *hermit_output_ptr++ = *in++; + crc = crc_32_tab[((int)crc ^ ch) & 0xff] ^ (crc >> 8); + } + if (hermit_progress >= 0) { + hprintf("."); + progress(); + } +} + +static void *malloc(int size) +{ + void *p; + + assert(size >= 0 || hermit_free_mem_ptr > 0); + hermit_free_mem_ptr = (hermit_free_mem_ptr + 3) & ~3; /* align */ + assert(hermit_free_mem_ptr + size <= hermit_free_mem_ptr_end); + + p = (void*) hermit_free_mem_ptr; + hermit_free_mem_ptr += size; + return p; +} + +static void free(void *where) +{ + /* gzip_mark and gzip_release do the free */ +} + +static void gzip_mark(void **ptr) +{ + *ptr = (void*) hermit_free_mem_ptr; +} + +static void gzip_release(void **ptr) +{ + hermit_free_mem_ptr = (long) *ptr; +} + +/* common initialization for the gunzip code */ +static void hermit_gunzip_init(void) +{ + window = (uch*) (GUNZIP_MEM_BASE + GUNZIP_MEM_SIZE); + bytes_out = 0; + makecrc(); +} + +void gunzip_object (char * name, addr_t from, addr_t to) +{ + /* initialize variables for decompression */ + hermit_gunzip_init(); + hermit_input_ptr = (uch*) from; + hermit_free_mem_ptr = WSIZE + (ulg) window; + hermit_free_mem_ptr_end = hermit_free_mem_ptr + HERMIT_HEAP_SIZE; + hermit_output_ptr = (uch*) to; + + /* decompress kernel image to DRAM */ + hprintf("Uncompressing %s", name); + gunzip(); + hprintf("done.\n"); +} + diff -urN hermit-1.3/src/target/cs89712/gunzip.h hermit/src/target/cs89712/gunzip.h --- hermit-1.3/src/target/cs89712/gunzip.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/gunzip.h Tue Jul 10 18:35:04 2001 @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_TARGET_GUNZIP_H +#define _HERMIT_TARGET_GUNZIP_H + +#include +#include "memregions.h" + +#define GUNZIP_MEM_SIZE 0x20000 +#define GUNZIP_MEM_BASE (DRAM1_START + DRAM1_SIZE - GUNZIP_MEM_SIZE - 0x10000) + +extern void gunzip_object (char * name, addr_t from, addr_t to); + +#endif /* _HERMIT_TARGET_GUNZIP_H */ diff -urN hermit-1.3/src/target/cs89712/init.S hermit/src/target/cs89712/init.S --- hermit-1.3/src/target/cs89712/init.S Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/init.S Tue Jul 10 13:17:40 2001 @@ -0,0 +1,20 @@ +/* + * init.S: assembly language bootstrap + */ + +#ifdef BOOTMODE +#define STACK_REGION 0x10000000 /* 48 kB on-chip SRAM */ +#define STACK_OFFSET 0x0000C000 /* full size of SRAM */ +#else +#define STACK_REGION 0xc0800000 /* second DRAM bank */ +#define STACK_OFFSET 0x00800000 /* full size of DRAM bank 2 */ +#endif + + .section .ram.boot + .global _start_ram +_start_ram: + mov sp, #STACK_REGION /* init stack pointer */ + add sp, sp, #STACK_OFFSET + bl entry /* see entry.c */ +1: b 1b + diff -urN hermit-1.3/src/target/cs89712/linux.c hermit/src/target/cs89712/linux.c --- hermit-1.3/src/target/cs89712/linux.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/linux.c Mon Jul 16 13:17:42 2001 @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include +#include +#include +#include "tags.h" +#include "gunzip.h" +#include "linux.h" +#include "memmap.h" +#include "memzero.h" + +/* for setting the root device */ +#define MINORBITS 8 +#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi)) + +#define RAMDISK_MAJOR 1 /* major for "RAM disk" */ +#define RAMDISK0_MINOR 0 /* b 1 0 == /dev/ram0 */ + +#define ROM_FLASH_MAJOR 31 /* major for "ROM/flash memory card" */ +#define FLASH0_MINOR 16 /* b 31 16 == /dev/flash0 */ +#define FLASH1_MINOR 17 /* b 31 17 == /dev/flash1 */ + +#define COMMAND_LINE_SIZE 1024 + +static int linux_cmdfunc(int argc, char *argv[]) +{ + struct tag *tag = (struct tag *) LINUX_PARAM_ADDRESS; + + /* zero param block */ + memzero (tag, LINUX_PARAM_SIZE); + + /* set up core tag */ + tag->hdr.tag = ATAG_CORE; + tag->hdr.size = tag_size(tag_core); + tag->u.core.flags = 0; + tag->u.core.pagesize = 0x1000; + tag->u.core.rootdev = MKDEV(RAMDISK_MAJOR, RAMDISK0_MINOR); + + /* 16 MB of SDRAM at 0xc0000000 */ + tag = tag_next(tag); + tag->hdr.tag = ATAG_MEM; + tag->hdr.size = tag_size(tag_mem32); + tag->u.mem.size = DRAM1_SIZE >> 12; + tag->u.mem.start = DRAM1_START; + + /* an initial ramdisk image in flash at 0x00700000 */ + tag = tag_next(tag); + tag->hdr.tag = ATAG_INITRD; + tag->hdr.size = tag_size(tag_initrd); + tag->u.initrd.start = INITRD_LOAD_ADDRESS; + tag->u.initrd.size = INITRD_SIZE; + + /* the command line arguments */ + if (argc > 1) { + tag = tag_next(tag); + tag->hdr.tag = ATAG_CMDLINE; + tag->hdr.size = (COMMAND_LINE_SIZE + 3 + + sizeof(struct tag_header)) >> 2; + + { + const unsigned char *src; + unsigned char *dst; + dst = tag->u.cmdline.cmdline; + memzero (dst, COMMAND_LINE_SIZE); + while (--argc > 0) { + src = *++argv; + hprintf ("Doing %s\n", src); + while (*src) + *dst++ = *src++; + *dst++ = ' '; + } + *--dst = '\0'; + } + } + + tag = tag_next(tag); + tag->hdr.tag = 0; + tag->hdr.size = 0; + + /* branch to kernel image */ + __asm__ volatile ( + " mov r4, #0xC0000000\n" /* start of DRAM */ + " add r4, r4, #0x00028000\n" /* kernel offset */ + " mov r0, #0\n" /* kernel sanity check */ + " mov r1, #123\n" /* CDB89712 arch. number */ + " mov r2, #0\n" + " mov r3, #0\n" + " mov pc, r4" /* go there! */ + ); + + /* never get here */ + return 0; +} + +static int unzip_cmdfunc(int argc, char *argv[]) +{ + addr_t kernel; + addr_t ramdisk; + + if (argc < 2 || argc > 3) + return -H_EUSAGE; + + argv++; + if (scan(*argv, &kernel)) + return -H_EADDR; + + argv++; + if (scan(*argv, &ramdisk)) + return -H_EADDR; + + /* turn on LED flasher (25% duty cycle) */ + IO_LEDFLSH = 0x4c; + + /* decompress kernel image to DRAM */ + gunzip_object (" kernel", kernel, LINUX_LOAD_ADDRESS); + gunzip_object ("ramdisk", ramdisk, INITRD_LOAD_ADDRESS); + + /* turn off LED flasher */ + IO_LEDFLSH = 0; + + return 0; +} + +static int boot_cmdfunc(int argc, char *argv[]) +{ + if (argc < 1) + return -H_EUSAGE; + + IO_LEDFLSH = 0x4c; + gunzip_object (" kernel", 0x100000, LINUX_LOAD_ADDRESS); + gunzip_object ("ramdisk", 0x200000, INITRD_LOAD_ADDRESS); + IO_LEDFLSH = 0; + + linux_cmdfunc (argc, argv); + + return 0; +} + +const command_t linux_command = + { "linux", "", "start Linux", &linux_cmdfunc }; +const command_t unzip_command = + { "unzip", " ", "unzip Linux kernel and ramdisk from addrs", &unzip_cmdfunc }; +const command_t boot_command = + { "boot", "", "boot default Linux kernel and ramdisk", &boot_cmdfunc }; + diff -urN hermit-1.3/src/target/cs89712/linux.h hermit/src/target/cs89712/linux.h --- hermit-1.3/src/target/cs89712/linux.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/linux.h Tue Jul 10 18:45:53 2001 @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_TARGET_LINUX_H +#define _HERMIT_TARGET_LINUX_H + +#include + +#define LINUX_PARAM_SIZE (0x00000f00) +#define LINUX_PARAM_ADDRESS (DRAM1_START + 0x00000100) +#define LINUX_LOAD_ADDRESS (DRAM1_START + 0x00028000) + +#define INITRD_SIZE (0x00200000) +#define INITRD_LOAD_ADDRESS (DRAM1_START + 0x00300000) + +extern const command_t linux_command; +extern const command_t unzip_command; +extern const command_t boot_command; + +#endif /* _HERMIT_TARGET_LINUX_H */ diff -urN hermit-1.3/src/target/cs89712/loader.c hermit/src/target/cs89712/loader.c --- hermit-1.3/src/target/cs89712/loader.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/loader.c Tue Jul 10 18:46:30 2001 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include +#include +#include +#include "eth.h" +#include "flash.h" +#include "frob.h" +#include "linux.h" +#include "memmap.h" + +/* timeout for auto-boot, in seconds */ +#define BOOT_TIMEOUT 5 + +static const command_t *commands[] = { + &help_command, + &boot_command, + &download_command, + &flash_erase_command, + ðer_mac_command, + &frob_command, + &jump_command, + &linux_command, + &medium_command, + &memmap_command, + &flash_program_command, + &unzip_command, + &upload_command, + &version_command, + 0 +}; + +ABBR(boot_command, 'b') +ABBR(help_command, '?') +ABBR(frob_command, 'f') +ABBR(version_command, 'V') + +static const abbrev_t *abbrevs[] = { + &boot_command_abbrev, + &help_command_abbrev, + &frob_command_abbrev, + &version_command_abbrev, + 0 +}; + +static inline void maybe_start_linux(void) +{ +#if defined STANDALONE + /* always go to the command loop */ +#else + /* boot linux unless a key is pressed before the timeout elapses */ + hprintf("Press a key within %d seconds for console.\n", BOOT_TIMEOUT); + IO_RTCMR = IO_RTCDR + BOOT_TIMEOUT; + while (IO_SYSFLG1 & URXFE1) { + if (IO_RTCMR <= IO_RTCDR) { + /* start linux */ + } + } +#endif +} + +int main(void) +{ + command_list_t command_list = { commands, abbrevs, "hermit", 0 }; + + maybe_start_linux(); + + /* startup stuff: activate LED and print version string */ + (*version_command.func)(0, 0); + init_crc32(); + IO_LEDFLSH = 0x7c; /* LED continuous on */ + do_command_loop(&command_list); + for (;;); +} + diff -urN hermit-1.3/src/target/cs89712/loader.lds.bootmode hermit/src/target/cs89712/loader.lds.bootmode --- hermit-1.3/src/target/cs89712/loader.lds.bootmode Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/loader.lds.bootmode Tue Jul 10 15:06:34 2001 @@ -0,0 +1,131 @@ +ENTRY(_start_ram) + +MEMORY +{ + SRAM : ORIGIN = 0x10000000, LENGTH = 0xc000 + DRAM1 : ORIGIN = 0xc0000000, LENGTH = 0x01000000 +} + +SECTIONS +{ + /* same as the Linux kernel start address */ + . = 0xC0028000; + + /* .text: machine instructions */ + .text BLOCK(32): + { + __text_start = ABSOLUTE(.); + + *(.ram.boot) /* must come first */ + *(.hermit.version) + + *(.text) /* program text (code) */ + *(.text.*) /* annotated text sections */ + *(.stub) + *(.gnu.warning) + *(.gnu.linkonce.t*) + *(.glue_7t) + *(.glue_7) + *(.rodata) /* read-only data */ + *(.rodata.*) /* read-only data */ + *(.gnu.linkonce.r*) + *(.rodata1) /* read-only data */ + *(.sdata2) + + *(.eh_frame) + *(.gcc_except_table) + *(.got) /* global offset table */ + *(.dynamic) + + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + + *(.got.plt) + + __text_end = ABSOLUTE(.); + } >DRAM1 + + /* .data: initialized data */ + .data BLOCK(32): + { + __data_start = ABSOLUTE(.); + *(.data) /* initialized writeable data */ + *(.data.*) /* initialized writeable data */ + *(.gnu.linkonce.d*) + *(.data1) + __data_end = ABSOLUTE(.); + } >DRAM1 + + /* .bss: uninitialized data (must be zeroed) */ + .bss BLOCK(32): + { + __bss_start = ABSOLUTE(.); + *(.sbss) + *(.dynsbss) + *(.sbss.*) + *(.sbss2) + *(.scommon) + *(.bss) /* uninitialized data (zeroed) */ + *(.dynbss) + *(.bss.*) /* uninitialized data (zeroed) */ + *(COMMON) + __bss_end = ABSOLUTE(.); + } >DRAM1 + + /* .unused: stuff we don't want in the loader */ + .unused 0: + { + *(.ctors) /* constructors */ + *(.dtors) /* destructors */ + *(.init) /* initialization code */ + *(.fini) /* termination code */ + *(.note.ABI-tag) + + *(.interp) /* path name of program interpreter */ + *(.hash) /* symbol hash table */ + *(.dynsym) /* dynamic linking symbol table */ + *(.dynstr) + *(.gnu.version) + *(.gnu.version_d) + *(.gnu.version_r) + *(.plt) /* procedure linkage table */ + + *(.rel.init) /* relocation information... */ + *(.rela.init) + *(.rel.text) + *(.rela.text) + *(.rel.fini) + *(.rela.fini) + *(.rel.rodata) + *(.rela.rodata) + *(.rel.data) + *(.rela.data) + *(.rel.ctors) + *(.rela.ctors) + *(.rel.dtors) + *(.rela.dtors) + *(.rel.got) + *(.rela.got) + *(.rel.sdata) + *(.rela.sdata) + *(.rel.sbss) + *(.rela.sbss) + *(.rel.sdata2) + *(.rela.sdata2) + *(.rel.sbss2) + *(.rela.sbss2) + *(.rel.bss) + *(.rela.bss) + *(.rel.plt) + *(.rela.plt) + + *(.stab) /* symbol table (debugging)... */ + *(.stabstr) + *(.stab.excl) + *(.stab.exclstr) + *(.stab.index) + *(.stab.indexstr) + } +} + diff -urN hermit-1.3/src/target/cs89712/loader.lds.flash hermit/src/target/cs89712/loader.lds.flash --- hermit-1.3/src/target/cs89712/loader.lds.flash Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/loader.lds.flash Tue Jul 10 15:06:38 2001 @@ -0,0 +1,140 @@ +ENTRY(_start_flash) + +MEMORY +{ + FLASH1 : ORIGIN = 0x00000000, LENGTH = 0x00800000 + SRAM : ORIGIN = 0x60000000, LENGTH = 0xc000 + DRAM1 : ORIGIN = 0xc0000000, LENGTH = 0x01000000 +} + +SECTIONS +{ + /* boot code: not relocated */ + .boot BLOCK(32): + { + *(.flash.boot) + entry.o(*) + } >FLASH1 + + /* begin VMAs at the start of SRAM */ + __text_start_flash = .; + . = 0x60000000; + + .text BLOCK(32): AT(__text_start_flash) + { + __text_start = ABSOLUTE(.); + + *(.ram.boot) /* must come first */ + *(.hermit.version) + + *(.text) /* program text (code) */ + *(.text.*) /* annotated text sections */ + *(.stub) + *(.gnu.warning) + *(.gnu.linkonce.t*) + *(.glue_7t) + *(.glue_7) + *(.rodata) /* read-only data */ + *(.rodata.*) /* read-only data */ + *(.gnu.linkonce.r*) + *(.rodata1) /* read-only data */ + *(.sdata2) + + *(.eh_frame) + *(.gcc_except_table) + *(.got) /* global offset table */ + *(.dynamic) + + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + + *(.got.plt) + + __text_end = ABSOLUTE(.); + } >SRAM =0 + + /* .data: initialized data (must be relocated to RAM) */ + __data_start_flash = LOADADDR(.text) + SIZEOF(.text); + .data BLOCK(32): AT(__data_start_flash) + { + __data_start = ABSOLUTE(.); + *(.data) /* initialized writeable data */ + *(.data.*) /* initialized writeable data */ + *(.gnu.linkonce.d*) + *(.data1) + __data_end = ABSOLUTE(.); + } >SRAM =0 + + /* .bss: uninitialized data (must be zeroed) */ + .bss BLOCK(32): + { + __bss_start = ABSOLUTE(.); + *(.sbss) + *(.dynsbss) + *(.sbss.*) + *(.sbss2) + *(.scommon) + *(.bss) /* uninitialized data (zeroed) */ + *(.dynbss) + *(.bss.*) /* uninitialized data (zeroed) */ + *(COMMON) + __bss_end = ABSOLUTE(.); + } >SRAM + + /* .unused: stuff we don't want in the loader */ + .unused 0: + { + *(.ctors) /* constructors */ + *(.dtors) /* destructors */ + *(.init) /* initialization code */ + *(.fini) /* termination code */ + *(.note.ABI-tag) + + *(.interp) /* path name of program interpreter */ + *(.hash) /* symbol hash table */ + *(.dynsym) /* dynamic linking symbol table */ + *(.dynstr) + *(.gnu.version) + *(.gnu.version_d) + *(.gnu.version_r) + *(.plt) /* procedure linkage table */ + + *(.rel.init) /* relocation information... */ + *(.rela.init) + *(.rel.text) + *(.rela.text) + *(.rel.fini) + *(.rela.fini) + *(.rel.rodata) + *(.rela.rodata) + *(.rel.data) + *(.rela.data) + *(.rel.ctors) + *(.rela.ctors) + *(.rel.dtors) + *(.rela.dtors) + *(.rel.got) + *(.rela.got) + *(.rel.sdata) + *(.rela.sdata) + *(.rel.sbss) + *(.rela.sbss) + *(.rel.sdata2) + *(.rela.sdata2) + *(.rel.sbss2) + *(.rela.sbss2) + *(.rel.bss) + *(.rela.bss) + *(.rel.plt) + *(.rela.plt) + + *(.stab) /* symbol table (debugging)... */ + *(.stabstr) + *(.stab.excl) + *(.stab.exclstr) + *(.stab.index) + *(.stab.indexstr) + } +} + diff -urN hermit-1.3/src/target/cs89712/loader.lds.kernel hermit/src/target/cs89712/loader.lds.kernel --- hermit-1.3/src/target/cs89712/loader.lds.kernel Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/loader.lds.kernel Tue Jul 10 15:06:43 2001 @@ -0,0 +1,128 @@ +ENTRY(_start_ram) + +MEMORY +{ + SRAM : ORIGIN = 0x60000000, LENGTH = 0xc000 + DRAM1 : ORIGIN = 0xc0000000, LENGTH = 0x01000000 +} + +SECTIONS +{ + . = 0xC0028000; + .text BLOCK(32): + { + __text_start = ABSOLUTE(.); + + *(.ram.boot) /* must come first */ + *(.hermit.version) + + *(.text) /* program text (code) */ + *(.text.*) /* annotated text sections */ + *(.stub) + *(.gnu.warning) + *(.gnu.linkonce.t*) + *(.glue_7t) + *(.glue_7) + *(.rodata) /* read-only data */ + *(.rodata.*) /* read-only data */ + *(.gnu.linkonce.r*) + *(.rodata1) /* read-only data */ + *(.sdata2) + + *(.eh_frame) + *(.gcc_except_table) + *(.got) /* global offset table */ + *(.dynamic) + + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + + *(.got.plt) + + __text_end = ABSOLUTE(.); + } >DRAM1 + + /* .data: initialized data (must be relocated to RAM) */ + .data BLOCK(32): + { + __data_start = ABSOLUTE(.); + *(.data) /* initialized writeable data */ + *(.data.*) /* initialized writeable data */ + *(.gnu.linkonce.d*) + *(.data1) + __data_end = ABSOLUTE(.); + } >DRAM1 + + /* .bss: uninitialized data (must be zeroed) */ + .bss BLOCK(32): + { + __bss_start = ABSOLUTE(.); + *(.sbss) + *(.dynsbss) + *(.sbss.*) + *(.sbss2) + *(.scommon) + *(.bss) /* uninitialized data (zeroed) */ + *(.dynbss) + *(.bss.*) /* uninitialized data (zeroed) */ + *(COMMON) + __bss_end = ABSOLUTE(.); + } >DRAM1 + + /* .unused: stuff we don't want in the loader */ + .unused 0: + { + *(.ctors) /* constructors */ + *(.dtors) /* destructors */ + *(.init) /* initialization code */ + *(.fini) /* termination code */ + *(.note.ABI-tag) + + *(.interp) /* path name of program interpreter */ + *(.hash) /* symbol hash table */ + *(.dynsym) /* dynamic linking symbol table */ + *(.dynstr) + *(.gnu.version) + *(.gnu.version_d) + *(.gnu.version_r) + *(.plt) /* procedure linkage table */ + + *(.rel.init) /* relocation information... */ + *(.rela.init) + *(.rel.text) + *(.rela.text) + *(.rel.fini) + *(.rela.fini) + *(.rel.rodata) + *(.rela.rodata) + *(.rel.data) + *(.rela.data) + *(.rel.ctors) + *(.rela.ctors) + *(.rel.dtors) + *(.rela.dtors) + *(.rel.got) + *(.rela.got) + *(.rel.sdata) + *(.rela.sdata) + *(.rel.sbss) + *(.rela.sbss) + *(.rel.sdata2) + *(.rela.sdata2) + *(.rel.sbss2) + *(.rela.sbss2) + *(.rel.bss) + *(.rela.bss) + *(.rel.plt) + *(.rela.plt) + + *(.stab) /* symbol table (debugging)... */ + *(.stabstr) + *(.stab.excl) + *(.stab.exclstr) + *(.stab.index) + *(.stab.indexstr) + } +} + diff -urN hermit-1.3/src/target/cs89712/medium.c hermit/src/target/cs89712/medium.c --- hermit-1.3/src/target/cs89712/medium.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/medium.c Tue Jul 10 13:47:25 2001 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include +#include +#include +#include +#include +#include "eth.h" + +typedef enum medium_type { + MEDIUM_SERIAL = 0, + MEDIUM_ETHERNET +} medium_t; +static medium_t current_medium; + +/* buffer used to read commands from the Ethernet interface */ +static unsigned char ethdata [128]; +static int ethdata_count, ethdata_pos; + +int hgetchar(void) +{ + if (current_medium == MEDIUM_SERIAL) { + while (IO_SYSFLG1 & URXFE1); + return IO_UARTDR1 & 0xff; + } + /* ethernet commands */ + if (ethdata_pos == ethdata_count) { + /* read a packet from the Ethernet */ + ethdata_count = ether_read(ethdata, sizeof ethdata); + assert(ethdata_count > 0); + assert(ethdata_count <= sizeof ethdata); + ethdata_pos = 0; + } + return ethdata[ethdata_pos++]; +} + +int hputchar(int c) +{ + while (IO_SYSFLG1 & UTXFF1); + IO_UARTDR1 = (unsigned char) c; + return 0; +} + +int hgetblock(unsigned char *dst, int count) +{ + int remain = count; + if (current_medium == MEDIUM_SERIAL) { + while (remain--) + *dst++ = hgetchar(); + } else { + assert(current_medium == MEDIUM_ETHERNET); + while (remain > 0) { + int nread = ether_read(dst, remain); + assert(nread <= remain); + dst += nread; + remain -= nread; + } + } + return count; +} + +/* + * This works for now, since medium only affects downstream data, not + * replies from the target to the host. Once we add upstream media + * switching, we'll have to implement a delayed media switch that + * allows the successful command return value to go out along the old + * medium. + */ +static int medium_cmdfunc(int argc, char *argv[]) +{ + medium_t medium; + + if (argc != 2) + return -H_EUSAGE; + ++argv; + if (!strcmp(*argv, "ethernet")) + medium = MEDIUM_ETHERNET; + else if (!strcmp(*argv, "serial")) + medium = MEDIUM_SERIAL; + else + return -H_EINVAL; + if (medium == current_medium) + return 0; + if (medium == MEDIUM_ETHERNET) { + if (ether_init() < 0) + return -H_EIO; + IO_LEDFLSH = 0x5c; /* LED 50% duty cycle */ + } else if (medium == MEDIUM_SERIAL) { + IO_LEDFLSH = 0x7c; /* LED continuous on */ + } + current_medium = medium; + return 0; +} + +const command_t medium_command = + { "medium", "", + "select communication medium", + &medium_cmdfunc }; + diff -urN hermit-1.3/src/target/cs89712/memmap.c hermit/src/target/cs89712/memmap.c --- hermit-1.3/src/target/cs89712/memmap.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/memmap.c Tue Jul 10 14:57:54 2001 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#include +#include +#include "memmap.h" + +static const char flash_blocking[] = "2x16K/l,6x16K,63x128K"; + +/* + * The only vaguely tricky things about this memory map are: + * + * (1) It includes remapped memory addresses for the inverted mapping + * used by the CSC in boot mode, if we're compiling for that + * target. + * + * (2) Depicts flash block sizes as they are seen from outside the + * boot loader. The flash parts are 16 bits wide (each spans 16 + * bits of the data bus), so the blocks as seen by a flash + * programmer are twice data sheet size (of each 32-bit write, 16 + * bits goes to each flash chip). + */ +static int memmap_cmdfunc(int argc, char *argv[]) +{ +#ifdef BOOTMODE + hprintf("%p:%p@%p FLA flash-1 bf:8K bl:%s\n" + "%p:%p@%p RAM onchip-sram\n" + "%p:%p@%p ROM boot-rom\n" + "%p:%p RAM dram-1\n", + FLASH_BANK1_START, FLASH_BANK1_START + FLASH_BANK1_SIZE - 1, FLASH_BANK1_MAPPED, + flash_blocking, + SRAM_START, SRAM_START + SRAM_SIZE - 1, SRAM_MAPPED, + BOOTROM_START, BOOTROM_START + BOOTROM_SIZE - 1, BOOTROM_MAPPED, + DRAM1_START, DRAM1_START + DRAM1_SIZE - 1); +#else + hprintf("%p:%p FLA flash-1 bf:8K bl:%s\n" + "%p:%p RAM onchip-sram\n" + "%p:%p ROM boot-rom\n" + "%p:%p RAM dram-1\n", + FLASH_BANK1_START, FLASH_BANK1_START + FLASH_BANK1_SIZE - 1, flash_blocking, + SRAM_START, SRAM_START + SRAM_SIZE - 1, + BOOTROM_START, BOOTROM_START + BOOTROM_SIZE - 1, + DRAM1_START, DRAM1_START + DRAM1_SIZE - 1); +#endif /* BOOTMODE */ + return 0; +} + +const command_t memmap_command = + { "memmap", 0, "output memory map", &memmap_cmdfunc }; + diff -urN hermit-1.3/src/target/cs89712/memmap.h hermit/src/target/cs89712/memmap.h --- hermit-1.3/src/target/cs89712/memmap.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/memmap.h Tue Jul 10 15:02:22 2001 @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_CDB89712_MEMMAP_H_ +#define _HERMIT_CDB89712_MEMMAP_H_ + +#include + +#include "memregions.h" + +extern const command_t memmap_command; + +#endif /* _HERMIT_CDB89712_MEMMAP_H_ */ + diff -urN hermit-1.3/src/target/cs89712/memregions.h hermit/src/target/cs89712/memregions.h --- hermit-1.3/src/target/cs89712/memregions.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/memregions.h Tue Jul 10 15:02:43 2001 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. + */ + +#ifndef _HERMIT_CDB89712_MEMREGIONS_H +#define _HERMIT_CDB89712_MEMREGIONS_H + +#define FLASH_BANK1_START 0x00000000 +#define FLASH_BANK1_SIZE 0x00800000 + +#define SRAM_START 0x60000000 +#define SRAM_SIZE 0x0000c000 + +#define BOOTROM_START 0x70000000 +#define BOOTROM_SIZE 0x00000080 + +#define DRAM1_START 0xC0000000 +#define DRAM1_SIZE 0x01000000 + +#ifdef BOOTMODE +#define FLASH_BANK1_MAPPED 0x70000000 +#define SRAM_MAPPED 0x10000000 +#define BOOTROM_MAPPED 0x00000000 +#endif + +/* + * External I/O regions are remapped by boot mode as well. + */ +#ifdef BOOTMODE +#define EXT_CS8900_BASE 0x50000300 +#else +#define EXT_CS8900_BASE 0x20000300 +#endif + +#endif /* _HERMIT_CDB89712_MEMREGIONS_H */ + diff -urN hermit-1.3/src/target/cs89712/memzero.c hermit/src/target/cs89712/memzero.c --- hermit-1.3/src/target/cs89712/memzero.c Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/memzero.c Tue Jul 10 13:17:40 2001 @@ -0,0 +1,45 @@ +#include "memzero.h" + +/* optimized C memzero for the ARM */ +void memzero(void *s, unsigned n) +{ + union { void *vp; unsigned long *ulp; unsigned char *ucp; } u; + int i; + + u.vp = s; + + for (i = n >> 5; i > 0; i--) { + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + } + + if (n & 1 << 4) { + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + *u.ulp++ = 0; + } + + if (n & 1 << 3) { + *u.ulp++ = 0; + *u.ulp++ = 0; + } + + if (n & 1 << 2) + *u.ulp++ = 0; + + if (n & 1 << 1) { + *u.ucp++ = 0; + *u.ucp++ = 0; + } + + if (n & 1) + *u.ucp++ = 0; +} + diff -urN hermit-1.3/src/target/cs89712/memzero.h hermit/src/target/cs89712/memzero.h --- hermit-1.3/src/target/cs89712/memzero.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/memzero.h Tue Jul 10 13:17:40 2001 @@ -0,0 +1,6 @@ +#ifndef _HERMIT_TARGET_MEMZERO_H +#define _HERMIT_TARGET_MEMZERO_H + +extern void memzero(void *s, unsigned n); + +#endif /* _HERMIT_TARGET_MEMZERO_H */ diff -urN hermit-1.3/src/target/cs89712/tags.h hermit/src/target/cs89712/tags.h --- hermit-1.3/src/target/cs89712/tags.h Wed Dec 31 17:00:00 1969 +++ hermit/src/target/cs89712/tags.h Tue Jul 10 16:34:21 2001 @@ -0,0 +1,154 @@ +#ifndef _HERMIT_TARGET_TAGS_H +#define _HERMIT_TARGET_TAGS_H + +/* lifted from linux/include/asm-arm/setup.h */ + +#include + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; + + +#define ATAG_NONE 0x00000000 + +struct tag_header { + u32 size; + u32 tag; +}; + +#define ATAG_CORE 0x54410001 + +struct tag_core { + u32 flags; /* bit 0 = read-only */ + u32 pagesize; + u32 rootdev; +}; + +#define ATAG_MEM 0x54410002 + +struct tag_mem32 { + u32 size; + u32 start; +}; + +#define ATAG_VIDEOTEXT 0x54410003 + +struct tag_videotext { + u8 x; + u8 y; + u16 video_page; + u8 video_mode; + u8 video_cols; + u16 video_ega_bx; + u8 video_lines; + u8 video_isvga; + u16 video_points; +}; + +#define ATAG_RAMDISK 0x54410004 + +struct tag_ramdisk { + u32 flags; /* b0 = load, b1 = prompt */ + u32 size; + u32 start; +}; + +#define ATAG_INITRD 0x54410005 + +struct tag_initrd { + u32 start; + u32 size; +}; + +#define ATAG_SERIAL 0x54410006 + +struct tag_serialnr { + u32 low; + u32 high; +}; + +#define ATAG_REVISION 0x54410007 + +struct tag_revision { + u32 rev; +}; + +#define ATAG_VIDEOLFB 0x54410008 + +struct tag_videolfb { + u16 lfb_width; + u16 lfb_height; + u16 lfb_depth; + u16 lfb_linelength; + u32 lfb_base; + u32 lfb_size; + u8 red_size; + u8 red_pos; + u8 green_size; + u8 green_pos; + u8 blue_size; + u8 blue_pos; + u8 rsvd_size; + u8 rsvd_pos; +}; + +#define ATAG_CMDLINE 0x54410009 + +struct tag_cmdline { + char cmdline[1]; +}; + +#define ATAG_ACORN 0x41000101 + +struct tag_acorn { + u32 memc_control_reg; + u32 vram_pages; + u8 sounddefault; + u8 adfsdrives; +}; + +#define ATAG_MEMCLK 0x41000402 + +struct tag_memclk { + u32 fmemclk; +}; + +struct tag { + struct tag_header hdr; + union { + struct tag_core core; + struct tag_mem32 mem; + struct tag_videotext videotext; + struct tag_ramdisk ramdisk; + struct tag_initrd initrd; + struct tag_serialnr serialnr; + struct tag_revision revision; + struct tag_videolfb videolfb; + struct tag_cmdline cmdline; + + /* + * Acorn specific + */ + struct tag_acorn acorn; + + /* + * DC21285 specific + */ + struct tag_memclk memclk; + } u; +}; + +struct tagtable { + u32 tag; + int (*parse)(const struct tag *); +}; + +#define tag_member_present(tag,member) \ + ((unsigned long)(&((struct tag *)0L)->member + 1) \ + <= (tag)->hdr.size * 4) + +#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) +#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) + +#endif /* _HERMIT_TARGET_TAGS_H */