2 * fwflash.c - handling the betty flashes
4 * author: hackbard@hackdaworld.org
19 #define BANK0 0x80000000
20 #define BANK2 0x82000000
24 #define CMD_CHIP_ERASE 'E'
32 typedef unsigned char u8;
33 typedef unsigned short u16;
34 typedef unsigned int u32;
40 #define TX_BYTE(x) while(!(UART0_LSR&(1<<5))) continue; \
43 #define SEND_OK TX_BYTE('o'); TX_BYTE('k'); TX_BYTE('\n'); \
50 void mmap_init(u8 memtype);
51 void uart0_init(void);
52 void uart0_send_string(char *txbuf);
53 void uart0_send_char(char send);
63 u32 i,addrlen,datalen;
70 /* memory mapping of interrupt vectors to static ram */
72 //mmap_init(MMAP_RAM);
74 /* uart initialization */
78 PINSEL0=0x05; // pin select -> tx, rx
79 UART0_FCR=0x07; // enable fifo
80 UART0_LCR=0x83; // set dlab + word length
81 UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
83 UART0_LCR=0x03; // unset dlab
85 /* external memory init */
87 BCFG0=0x1000FBEF; // no boot[1:0] influence? (thnx colibri)
88 // BCFG2 should be fine as is
90 /* begin the main loop */
96 while(!(UART0_LSR&(1<<0)))
100 if(cmd==CMD_CHIP_ERASE) {
114 /* receive (only if there is) more data from uart0 */
117 for(i=0;i<addrlen;i++) {
118 while(!(UART0_LSR&(1<<0)))
125 for(i=0;i<datalen;i++) {
126 while(!(UART0_LSR&(1<<0)))
132 /* process the cmd */
137 for(i=0;i<buf[0];i++) {
150 dptr=(u16 *)(addr|0x555);
153 dptr=(u16 *)(addr|0x2aa);
156 dptr=(u16 *)(addr|0x555);
160 dptr=(u16 *)(addr|0x2aa);
163 dptr=(u16 *)(addr|0x555);
171 /* send an ack, the cmd! */
183 void mmap_init(u8 memtype) {
188 void uart0_init(void) {
190 PINSEL0=0x05; // pin select -> tx, rx
191 UART0_FCR=0x07; // enable fifo
192 UART0_LCR=0x83; // set dlab + word length
193 UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
195 UART0_LCR=0x03; // unset dlab
198 void uart0_send_string(char *txbuf) {
205 UART0_THR=txbuf[i++];
209 while(!(UART0_LSR&(1<<6))) {}
212 void uart0_send_char(char send) {
214 while(!(UART0_LSR&(1<<5)))