2 * fwflash.c - handling the betty flashes
4 * author: hackbard@hackdaworld.org
19 #define BANK0 0x80000000
20 #define BANK2 0x82000000
21 #define B0HB 0x00000000
22 #define B2HB 0x02000000
26 #define CMD_CHIP_ERASE 'E'
34 typedef unsigned char u8;
35 typedef unsigned short u16;
36 typedef unsigned int u32;
42 #define TX_BYTE(x) while(!(UART0_LSR&(1<<5))) continue; \
45 #define SEND_OK TX_BYTE('o'); TX_BYTE('k'); TX_BYTE('\n'); \
52 void mmap_init(u8 memtype);
53 void uart0_init(void);
54 void uart0_send_string(char *txbuf);
55 void uart0_send_char(char send);
65 u32 i,addrlen,datalen;
72 /* memory mapping of interrupt vectors to static ram */
74 //mmap_init(MMAP_RAM);
76 /* uart initialization */
80 PINSEL0=0x05; // pin select -> tx, rx
81 UART0_FCR=0x07; // enable fifo
82 UART0_LCR=0x83; // set dlab + word length
83 UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
85 UART0_LCR=0x03; // unset dlab
87 /* external memory init */
89 BCFG0=0x1000FBEF; // no boot[1:0] influence? (thnx colibri)
90 // BCFG2 should be fine as is
92 /* begin the main loop */
98 while(!(UART0_LSR&(1<<0)))
102 if(cmd==CMD_CHIP_ERASE) {
116 /* receive (only if there is) more data from uart0 */
119 for(i=0;i<addrlen;i++) {
120 while(!(UART0_LSR&(1<<0)))
127 for(i=0;i<datalen;i++) {
128 while(!(UART0_LSR&(1<<0)))
134 /* process the cmd */
139 for(i=0;i<buf[0];i++) {
152 dptr=(u16 *)(addr|0x555);
155 dptr=(u16 *)(addr|0x2aa);
158 dptr=(u16 *)(addr|0x555);
162 dptr=(u16 *)(addr|0x2aa);
165 dptr=(u16 *)(addr|0x555);
173 /* send an ack, the cmd! */
185 void mmap_init(u8 memtype) {
190 void uart0_init(void) {
192 PINSEL0=0x05; // pin select -> tx, rx
193 UART0_FCR=0x07; // enable fifo
194 UART0_LCR=0x83; // set dlab + word length
195 UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
197 UART0_LCR=0x03; // unset dlab
200 void uart0_send_string(char *txbuf) {
207 UART0_THR=txbuf[i++];
211 while(!(UART0_LSR&(1<<6))) {}
214 void uart0_send_char(char send) {
216 while(!(UART0_LSR&(1<<5)))