I'm really interested in developing a 64-bit operating system. I have two questions:
1. Does a 64-bit operating system require a special computer, or could I run it from my current computer?
2. Where can I find information about setting up 64-bit mode (I think its called long mode)?
64-Bits?
Re: 64-Bits?
Hi,
Cheers,
Brendan
For 80x86, it requires a CPU that supports long mode (or an emulator that supports long mode, like Bochs or Qemu).Fear wrote:1. Does a 64-bit operating system require a special computer, or could I run it from my current computer?
From the current programmer's manuals from either Intel or AMD (they've both got example code for initialising long mode, to go with all the details).Fear wrote:2. Where can I find information about setting up 64-bit mode (I think its called long mode)?
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.
Hi,
A faster way would be to setup an invalid opcode exception handler, and then try to execute the CPUID instruction (whether it's supported or not). In this case if you get an invalid opcode exception then you know there's no long mode, and if you don't you only need to do the last 2 tests.
If your OS is started in protected mode (e.g. by GRUB), then you can skip the first 2 tests because you know it's at least capable of 32-bit....
Cheers,
Brendan
If you're in real mode, it could go something like:Fear wrote:How do I find out if my computer does support long mode? Is there some test to run?
Code: Select all
pushf
pop ax ;ax = original flags
test ah,0x80 ;Is bit 15 set?
jne .longModeNotSupported ; yes, old 8086!
xor ah,0x30 ;ax = flags with modified IOPL bits
push ax ;Save flags
popf ;Load flags
pushf ;Save modified flags
pop bx ;bx = modified flags
xor ax,bx ;ax = flags with changed bits set
test ah,0x30 ;Did IOPL bits change?
jne .longModeNotSupported ; no, not a 32 bit CPU
pushfd
mov eax,[esp] ;eax = original eflags
xor eax,0x00040000 ;Invert AC flag
push eax ;Store new eflags on stack
popfd ;Read new eflags
pushfd ;Store modified eflags
pop ebx ;ebx = flags after changing
xor eax,ebx ;If bits changed set them, else clear them
popfd ;Restore original eflags
test eax,0x40000 ;Is alignment check supported?
jne .longModeNotSupported ; no, not a 486 or later CPU
pushfd ;Save eflags
cli ;Disable interrupts
mov eax,[esp] ;eax = original eflags
mov ebx,eax ;ebx = original eflags
xor eax,0x200000 ;Invert ID flag
push eax ;Store new eflags on stack
popfd ;Read new eflags
pushfd ;Store modified eflags
pop eax ;eax = flags after changing
xor eax,ebx ;If bits changed set them, else clear them
popfd ;Restore original eflags (and interrupts)
test eax,0x200000 ;Is CPUID supported?
je .longModeNotSupported ; no
mov eax,0x80000000 ;eax = extended CPUID functions
cpuid ;Get maximum extended CPUID function
cmp eax,0x80000001 ;Is the extended feature flags function supported?
jb .longModeNotSupported ; no
mov eax,0x80000001 ;eax = extended feature flags function
cpuid ;Get the extended feature flags
test edx,0x20000000 ;Is long mode supported?
je .longModeNotSupported ; no
If your OS is started in protected mode (e.g. by GRUB), then you can skip the first 2 tests because you know it's at least capable of 32-bit....
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.
the best advice i can give is:
read the intel manuals (if you dont have them there is a link in my sig, and at the bottom of that page there is a link to ordering hard-copies -- definitely recommended)
make sure you thoroughly understand PMode first, as it is almost exactly like LMode (intel calls it IA-32e mode), dont be concerned if you dont understand right away, the general rule is read all of volume 3, then reread chapters 3,4, and 5
for information about initializing the CPU in LMode or PMode, chapter 9 particularly section 9.8 & 9.9 -- if you dont understand anything here, you should prob take a closer look at chapters 3 & 4
read the intel manuals (if you dont have them there is a link in my sig, and at the bottom of that page there is a link to ordering hard-copies -- definitely recommended)
make sure you thoroughly understand PMode first, as it is almost exactly like LMode (intel calls it IA-32e mode), dont be concerned if you dont understand right away, the general rule is read all of volume 3, then reread chapters 3,4, and 5
for information about initializing the CPU in LMode or PMode, chapter 9 particularly section 9.8 & 9.9 -- if you dont understand anything here, you should prob take a closer look at chapters 3 & 4