+ while(!(UART0_LSR&(1<<0)))
+ continue;
+ start=UART0_RBR;
+ if(start=='0') {
+ mem=(u16 *)BANK0;
+ len=0x80000;
+ break;
+ }
+ if(start=='2') {
+ mem=(u16 *)BANK2;
+ len=0x80000;
+ break;
+ }
+ if(start=='b') {
+ BCFG0=0x1000FBEF; // 32 bit width
+ bl=(u32 *)BOOTLOADER;
+ len=0x800;
+ break;
+ }
+ }
+
+ /* transmit 1 mb of data */
+ for(i=0;i<len;i++) { // care for endianness
+
+ while(!(UART0_LSR&(1<<5)))
+ continue;
+ if(start=='b')
+ UART0_THR=(*bl&0xff);
+ else
+ UART0_THR=(*mem&0xff);
+
+ while(!(UART0_LSR&(1<<5)))
+ continue;
+ if(start=='b')
+ UART0_THR=((*bl&0xff00)>>8);
+ else {
+ UART0_THR=((*mem&0xff00)>>8);
+ mem++;
+ }
+
+ if(start=='b') {
+ while(!(UART0_LSR&(1<<5)))
+ continue;
+ UART0_THR=((*bl&0xff0000)>>16);
+ while(!(UART0_LSR&(1<<5)))
+ continue;
+ UART0_THR=((*bl&0xff000000)>>24);
+ bl++;
+ }
+ }
+