pc/l.s: load virtual gdt pointer after mmu switch

before removing the double map at 0, load our
initial gdt pointer with its new KZERO based
virtual address.

this is prerequisite for handling traps early during
bootup before mmuinit() loads the final gdt.
front
cinap_lenrek 2020-11-17 23:18:08 +01:00
parent e8111e517d
commit 8cb33f2f18
1 changed files with 9 additions and 6 deletions

View File

@ -71,8 +71,7 @@ TEXT _multibootentry(SB), $0
STD
REP; MOVSB
MOVL BX, multibootptr-KZERO(SB)
MOVL $_startPADDR(SB), AX
ANDL $~KZERO, AX
MOVL $_startPADDR-KZERO(SB), AX
JMP* AX
/* multiboot structure pointer (physical address) */
@ -98,8 +97,7 @@ TEXT _startPADDR(SB), $0
CLI /* make sure interrupts are off */
/* set up the gdt so we have sane plan 9 style gdts. */
MOVL $tgdtptr(SB), AX
ANDL $~KZERO, AX
MOVL $tgdtptr-KZERO(SB), AX
MOVL (AX), GDTR
MOVW $1, AX
MOVW AX, MSW
@ -158,9 +156,11 @@ TEXT m0idtptr(SB), $0
WORD $(256*8-1)
LONG $IDTADDR
TEXT mode32bit(SB), $0
/* At this point, the GDT setup is done. */
TEXT vtgdtptr(SB), $0
WORD $(3*8)
LONG $tgdt(SB)
TEXT mode32bit(SB), $0
MOVL $((CPU0END-CPU0PDB)>>2), CX
MOVL $PADDR(CPU0PDB), DI
XORL AX, AX
@ -231,6 +231,9 @@ _setpte:
* be initialised here.
*/
TEXT _startpg(SB), $0
MOVL $vtgdtptr(SB), AX
MOVL (AX), GDTR
MOVL $0, (PDO(0))(CX) /* undo double-map of KZERO at 0 */
MOVL CX, CR3 /* load and flush the mmu */