64bit long mode questions...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Icydemon
Posts: 3
Joined: Sat Dec 15, 2007 7:25 am

64bit long mode questions...

Post 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
orange
Posts: 16
Joined: Sun Dec 16, 2007 11:13 pm

Re: 64bit long mode questions...

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: 64bit long mode questions...

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply