[rendering] This simple trick didn't work...
[wikipediardware.git] / mbr / mbr.c
blobd09626c00bab9c6bd0b622fe532ccb7beb4cbaa2
1 /*
2 e07 bootloader suite
3 Copyright (c) 2008 Daniel Mack <daniel@caiaq.de>
4 Copyright (c) 2009 Christopher Hall <hsw@openmoko.com>
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "regs.h"
21 #include "types.h"
22 #include "wikireader.h"
23 #include "eeprom.h"
25 #define APPLICATION_TITLE "mbr"
26 #include "application.h"
29 #define RAM_SIZE 8192
30 #define RAM_LOAD_ADDRESS 0x200
31 #define EEPROM_CODE_OFFSET 0x300
33 #define EEPROM_PAYLOAD_SIZE (RAM_SIZE - EEPROM_CODE_OFFSET)
35 #define DEST ((u8 *)RAM_LOAD_ADDRESS)
36 #define APPLICATION ((application *)RAM_LOAD_ADDRESS)
38 #define PRINT_CHAR(c) \
39 do { \
40 do { \
41 } while (0 == (REG_EFSIF0_STATUS & TDBEx)); \
42 REG_EFSIF0_TXD = c; \
43 } while (0)
46 // this defines the entry points to the MBR code
47 //__attribute__ ((noreturn))
48 void start(void)
50 asm volatile (
51 "\tjp\tmaster_boot\n" // location 0 - boot
52 "\t.extern\teeprom_load\n"
53 "\txjp\teeprom_load\n" // location 2 - so eeprom_load can be re-used
58 __attribute__ ((noreturn))
59 void master_boot(void)
61 asm volatile ("xld.w %r15, __dp");
63 register ReturnType rc = { 0, 0xffffffff };
65 for (;;) {
66 asm volatile ("xld.w %r15, __dp");
67 init_pins();
68 init_rs232_ch0();
69 //init_ram(); // but will be too big
71 // enable SPI: master mode, no DMA, 8 bit transfers
72 REG_SPI_CTL1 = 0x03 | (7 << 10);
74 //PRINT_CHAR('>');
75 PRINT_CHAR('\r');
76 PRINT_CHAR('\n');
77 eeprom_load((rc.block << 13) | EEPROM_CODE_OFFSET, DEST, EEPROM_PAYLOAD_SIZE);
79 rc = (APPLICATION)(rc.block, rc.status);
80 //PRINT_CHAR('<');