33,65 → 33,5 |
|
.global kernel_image_start |
|
.org 0x0 |
/* 256 bytes of some data */ |
/* exception table - must use 'ba' instructions for branches, |
* because it is elsewhere than the linker thinks |
*/ |
.space 4096 |
|
kernel_image_start: |
/* Initialize OFW, might be needed before relocate_kernel? */ |
lis r4, ofw@ha |
addi r4, r4, ofw@l |
stw r5, 0(r4) |
|
bl ofw_init |
bl preboot_read_config |
|
bl relocate_kernel |
__after_reloc: |
/* Set stack to some more meaningful value */ |
/* TODO: This is hardcoded for PearPC, must be changed later */ |
lis r1, 0x70 |
b main_bsp |
|
relocate_kernel: |
/* TODO: We _know_ that pearpc loads it to 8MB, and |
* but it should be really generic |
*/ |
lis r4, 0x80 /* r4 is where data was loaded - 8MB */ |
|
bl to_real_mode |
/* Now we are in real mode, copy first block and jump to it, |
* we are running in the loaded kernel now |
* We still have in r3 physical load kernel address |
*/ |
|
b __after_reloc /* We know in pearpc we are ok, so return, |
* otherwise we should relocate kernel |
* here |
*/ |
|
|
|
|
/* Turn off page translation |
* - assume that physical-loaded address is in r4 |
*/ |
to_real_mode: |
mflr r0 |
|
lis r5, ktext_start@ha // Expected start of kernel |
addi r5, r5, ktext_start@l |
|
add r0, r4, r0 |
sub r0, r0, r5 // r0 now contains physical return address |
|
mfmsr r3 |
andis. r3, r3, (~MSR_DR | MSR_IR) >> 16 |
mtspr SPRN_SRR0, r0 |
mtspr SPRN_SRR1, r3 |
sync // Really needed? RFI should do it as well? |
RFI |
|