Specifications

22 A Minimal PowerPCª Boot Sequence for
Executing Compiled C Programs
Source Files
// get the start address of the main routine of the code we want to run.
addis r3,r0,USER_ENTRY@h
ori r3,r3,USER_ENTRY@l
mtspr srr0,r3
// Set the MSR.
// we just move the value into srr1 - it will get copied into
// the msr upon the rfi.
#if VMX_AVAIL == 1
addis r4,0,0x0200
#else
addis r4,0,0x0000
#endif
ori r4,r4,0x3900 // turn on fp,
// enable fp & machine check exceptions
#if MMU_ON == 1
ori r4,r4,0x0030 // turn on I and D translation
#endif
// See if we relocated the code to an address above 0xffc00000.
// If so, put the exception prefix at 0xfff00000. Otherwise,
// make it at 0.
addis r5,0,0xffc0
ori r5,r5,0x0000
cmp 0,0,r5,r3
blt set_state
ori r4,r4,0x0040 // put exception prefix at 0xfff00000
// in our new msr
set_state:
// Put r4 into srr1 so it gets copied into the msr on rfi
mtspr srr1,r4
// letÕs put something in the link register - when the user program
// starts, itÕs going to save the link register, do itÕs thing, then
// restore the link register and blr.
// weÕll put in the address following the rfi so we can save
// off the time base once the user code is complete
addis r3,0,save_timebase@h
ori r3,r3,save_timebase@l
mtlr r3
// set up the time base register
addis r4,r0,0x0000
mtspr 285,r4
mtspr 284,r4
// Set up stack pointer for the user application