Page 1 of 1

64bit long mode questions...

Posted: Sat Dec 29, 2007 10:12 pm
by Icydemon
Hey there

After solving some problems i had with my bootloader (yes i decided to write my own :S) I came across AMD's manuals that say:

To jump into long mode you have to setup 32bit pmode first then reinitialise it for long mode.

a) is it possible to jump directly to long mode from real mode? (without the whole initialization stuff)
b) is it possible to go back to real mode without having problems (since no 32bit enviroment is initialized )
c) out of personal experience i have noticed that i can use 32bit gpr's even when im working on 16bits (e.g. EAX without having initialized 32bit mode) is it possible to use 64bit gprs too??

Thanks in advance

Re: 64bit long mode questions...

Posted: Sat Dec 29, 2007 11:09 pm
by orange
Icydemon wrote: a) is it possible to jump directly to long mode from real mode? (without the whole initialization stuff)
i thing not, you must in PM first then activate PAE, setting up paging, enable LME, enable paging and jump to long mode

Re: 64bit long mode questions...

Posted: Sun Dec 30, 2007 1:08 am
by Brendan
Hi,
Icydemon wrote:a) is it possible to jump directly to long mode from real mode? (without the whole initialization stuff)
Yes, I've done it before. You need to enable long mode in the MSR, then set the PG and PE flags in CR0 at the same time.
Icydemon wrote:b) is it possible to go back to real mode without having problems (since no 32bit enviroment is initialized )
I haven't tried this, but AFAIK it would be possible. You'd need to make sure your code is identity mapped below 1 MB, switch to a 16-bit segments in long mode, then clear the PE bit in CR0, then reload segment registers.
Icydemon wrote:c) out of personal experience i have noticed that i can use 32bit gpr's even when im working on 16bits (e.g. EAX without having initialized 32bit mode) is it possible to use 64bit gprs too??
No. Unless your code is 64-bit code the instruction prefixes that allow access to 64-bit GPRs behave differently (the CPU decodes them as other instructions, etc instead of as instruction prefixes).


Cheers,

Brendan