Changeset View
Standalone View
sys/powerpc/aim/locore64.S
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | 1: mflr %r3 | ||||
li %r3, 0 | li %r3, 0 | ||||
std %r3, 0(%r1) | std %r3, 0(%r1) | ||||
bl mi_startup | bl mi_startup | ||||
nop | nop | ||||
/* Unreachable */ | /* Unreachable */ | ||||
b . | b . | ||||
ASENTRY_NOPROF(__restartkernel_virtual) | |||||
/* | |||||
* When coming in via this entry point, we need to alter the SLB to | |||||
* shadow the segment register emulation entries in DMAP space. | |||||
* We need to do this dance because we are running with virtual-mode | |||||
* OpenFirmware and have not yet taken over the MMU. | |||||
* | |||||
* Assumptions: | |||||
* 1) The kernel is currently identity-mapped. | |||||
* 2) We are currently executing at an address compatible with | |||||
* real mode. | |||||
* 3) The first 16 SLB entries are emulating SRs. | |||||
* 4) The rest of the SLB is not in use. | |||||
* 5) OpenFirmware is not manipulating the SLB at runtime. | |||||
* 6) We are running on 64-bit AIM. | |||||
* | |||||
* Tested on a G5. | |||||
*/ | |||||
mfmsr %r14 | |||||
/* Switch to real mode because we are about to mess with the SLB. */ | |||||
bdragon: need to add to comment: "We exit real mode at the end of __restartkernel when we rfid." | |||||
andi. %r14, %r14, ~(PSL_DR|PSL_IR|PSL_ME|PSL_RI)@l | |||||
mtmsr %r14 | |||||
isync | |||||
/* Prepare variables for later use. */ | |||||
li %r14, 0 | |||||
li %r18, 0 | |||||
oris %r18, %r18, 0xc000 | |||||
bdragonAuthorUnsubmitted Not Done Inline ActionsI should probably be loading the SLBE relevant bits of DMAP_BASE_ADDRESS instead of hardcoding it here. bdragon: I should probably be loading the SLBE relevant bits of DMAP_BASE_ADDRESS instead of hardcoding… | |||||
sldi %r18, %r18, 32 /* r18: 0xc000000000000000 */ | |||||
1: | |||||
/* | |||||
* Loop over the first 16 SLB entries. | |||||
* Offset the SLBE into the DMAP, add 16 to the index, and write | |||||
* it back to the SLB. | |||||
*/ | |||||
/* XXX add more safety checks */ | |||||
slbmfev %r15, %r14 | |||||
bdragonAuthorUnsubmitted Done Inline ActionsI would love to know if anyone has any reason NOT to do this. As far as I can tell, 64 bit AIM using virtual mode OpenFirmware = Power Macintosh G5, full stop. Everything else that I'm aware of uses real mode OF and doesn't have to do this in the first place. bdragon: I would love to know if anyone has any reason NOT to do this.
As far as I can tell, 64 bit AIM… | |||||
slbmfee %r16, %r14 | |||||
or %r16, %r16, %r14 /* index is 0-15 */ | |||||
ori %r16, %r16, 0x10 /* add 16 to index. */ | |||||
or %r16, %r16, %r18 /* SLBE DMAP offset */ | |||||
rldicr %r17, %r16, 0, 37 /* Invalidation SLBE */ | |||||
isync | |||||
slbie %r17 | |||||
/* isync */ | |||||
bdragonAuthorUnsubmitted Not Done Inline ActionsI can probably tighten up on these syncs more than this. But meh, I'd rather not have to pore over openfirmware .register output any more than I have to. bdragon: I can probably tighten up on these syncs more than this. But meh, I'd rather not have to pore… | |||||
slbmte %r15, %r16 | |||||
isync | |||||
addi %r14, %r14, 1 | |||||
cmpdi %r14, 16 | |||||
blt 1b | |||||
#if 0 | |||||
Done Inline ActionsI should take this block back out before committing. bdragon: I should take this block back out before committing. | |||||
/* Hack: Install segment traps. OF is silly and skips them. */ | |||||
bdragonAuthorUnsubmitted Done Inline ActionsThis is actually the reason that those OFW decrementer traps happen -- Apple forgot to install the segment traps, so if there's a segment fault, it ends up faulting in a loop on the first instruction until the decrementer times out. I haven't tested this, because when I tried it, it didn't work. I later realized that the reason it didn't work was that I'd forgotten to icbi it. bdragon: This is actually the reason that those OFW decrementer traps happen -- Apple forgot to install… | |||||
li %r14, 0x43a6 | |||||
oris %r14, %r14, 0x7c10 | |||||
stw %r14, 0x380(0) | |||||
stw %r14, 0x480(0) | |||||
li %r14, 0x02a6 | |||||
oris %r14, %r14, 0x7c08 | |||||
stw %r14, 0x384(0) | |||||
stw %r14, 0x484(0) | |||||
li %r14, 0x4386 | |||||
oris %r14, %r14, 0x7c31 | |||||
stw %r14, 0x388(0) | |||||
stw %r14, 0x488(0) | |||||
li %r14, 0x01e3 /* Apple OF trap trampoline @ 0x01e3 */ | |||||
bdragonAuthorUnsubmitted Done Inline ActionsAnother way to do this is to check if the entire trap area for the trap is empty, and if so, copy the 0x?00-0x?7f bytes in. bdragon: Another way to do this is to check if the entire trap area for the trap is empty, and if so… | |||||
oris %r14, %r14, 0x4800 | |||||
stw %r14, 0x38c(0) | |||||
stw %r14, 0x48c(0) | |||||
sync | |||||
li %r14, 0x380 | |||||
dcbf 0, %r14 | |||||
icbi 0, %r14 | |||||
li %r14, 0x480 | |||||
dcbf 0, %r14 | |||||
icbi 0, %r14 | |||||
sync | |||||
#endif | |||||
ASENTRY_NOPROF(__restartkernel) | ASENTRY_NOPROF(__restartkernel) | ||||
/* | /* | ||||
* r3-r7: arguments to go to __start | * r3-r7: arguments to go to __start | ||||
* r8: offset from current kernel address to apply | * r8: offset from current kernel address to apply | ||||
* r9: MSR to set when (atomically) jumping to __start + r8 | * r9: MSR to set when (atomically) jumping to __start + r8 | ||||
*/ | */ | ||||
mtsrr1 %r9 | mtsrr1 %r9 | ||||
bl 1f | bl 1f | ||||
Show All 9 Lines |
need to add to comment: "We exit real mode at the end of __restartkernel when we rfid."