Hi,
I've been playing with long mode, and just thought I'd let you all know that it
is possible to go from real mode to long mode without any protected mode code (and without doing most of the things that the AMD manual says).
The algorithm I'm using is (starting from real mode with interrupts disabled):
1) Build paging structures (PML4, PDPT, PD and PTs)
2) Enable PAE in CR4
3) Set CR3 so it points to the PML4
4) Enable long mode in the EFER MSR
5) Enable paging and protected mode at the same time (activate long mode)
6) Load a GDT
7) Do a "far jump" to some 64 bit code
I've tested this code on a (very generously donated) 2.8 GHz Intel Celeron and Bochs, and it works fine on both.
For anyone interested I've put code and a bootable demo on my web site.
For the code itself, see:
http://bcos.hopto.org/temp/init.htmlFor a bootable floppy image, see:
http://bcos.hopto.org/temp/floppy144.imgAnd for a screenshot of what it should look like if it works, see:
http://bcos.hopto.org/temp/test64.jpgIf you boot the floppy image on a computer that does support long mode you should end up with vertical stripes down the screen, with some text underneath. If long mode isn't supported it'll lock up after saying something like "Starting 32 bit (or 36 bit) Kernel Setup Code".
I'm hoping this will save people the hassle of loading protected mode segments, a protected mode GDT, IDT, stack, etc - it all seems unnecessary.
Cheers,
Brendan