start_rom.c
816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "cpusim.h"
/* Please use romdump to find the entry
of your rom file
*/
#define ROM_ADDR 0x450
#define DDR_MASK 0x03FFFFFF
unsigned int start_addr=0xbabecafe;
int main()
{
vu32 *p0, s1, s2;
void (*f0)(void);
test_preamble();
setcp0reg(C0_SR, SR_CU0|SR_CU1|SR_BEV);
setcp0reg(C0_CONFIG, CONFIG_BE|CONFIG_NONCOHRNT);
initICache();
initDCache();
init_ddr();
message("Start rom\n");
/* Jump to rom start address */
s1 = (start_addr >> 16) & 0xffff;
s2 = start_addr & 0xffff; /* avoid signature */
if (s1 == 0xbabe && s2 == 0xcafe)
p0 = (vu32*) (PHYS_TO_K1(ROM_ADDR));
else
p0 = (vu32*) (PHYS_TO_K1((start_addr & DDR_MASK)));
f0 = (void(*))(p0);
setreg($30, 0);
setreg($29, 0xA0800000);
(*f0)();
message("End rom\n");
test_postamble();
return 0;
}