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/>.
22 #include "wikireader.h"
25 #define APPLICATION_TITLE "mbr"
26 #include "application.h"
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) \
41 } while (0 == (REG_EFSIF0_STATUS & TDBEx)); \
46 // this defines the entry points to the MBR code
47 //__attribute__ ((noreturn))
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 };
66 asm volatile ("xld.w %r15, __dp");
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);
77 eeprom_load((rc
.block
<< 13) | EEPROM_CODE_OFFSET
, DEST
, EEPROM_PAYLOAD_SIZE
);
79 rc
= (APPLICATION
)(rc
.block
, rc
.status
);