IanSeyler wrote:Just the bits that put the proper GDT and PML4 in place.
It doesn't make any sense to switch to protected mode to do either of these things.
Code: Select all
dq 0x0040980000000000 ; D(22), P(15), S(12), Type(11)
dq 0x0000900000000000 ; P(15), S(12)
All those bits that were ignored in 64-bit mode are not ignored in compatibility mode. At the very least, you need to set the limit high enough to access your code and data.
IanSeyler wrote:How does this look?
You don't need a separate GDT for each mode. You can load a single GDT that contains all of the segment descriptors you need.
You can just write "push 8". The immediate operand can be any value that can be sign-extended from 32 bits.
Does your assembler default to RIP-relative addressing? If not, this may cause relocation failures if the firmware loads your binary above 2GiB.
On AMD CPUs, far CALL doesn't support 64-bit offsets. Are you sure you didn't want to use RETFQ here instead?
Code: Select all
jmp 8:0x8000 ; 32-bit jump to set CS
UEFI doesn't guarantee fixed addresses will be usable memory. All code that runs before you switch to your own page tables must be relocatable.