Hello,
I have written a very small and simple operating system with a bootloader. I load a few sectors into memory and jump to it, then I enable A20 gate, setup a GDT and IDT, set the CPU to 32 bit, and jump to it. I end up in my 32 bit kernel written in C language.
Now I want to do it in 64 bit.
move to 64 bit OS
Re: move to 64 bit OS
Good to hear! Do you have any plans for how to port?
Re: move to 64 bit OS
I'm not sure of the exact nature of this topic.teodori wrote:Hello,
I have written a very small and simple operating system with a bootloader. I load a few sectors into memory and jump to it, then I enable A20 gate, setup a GDT and IDT, set the CPU to 32 bit, and jump to it. I end up in my 32 bit kernel written in C language.
Now I want to do it in 64 bit.
Is this a statement? Question? If (a), I think this sub forum is not the right one. Announcements, Job Openings (and something else) is the one to post in. Although, I suggest that more information should be included before posting there.
If this is a question on how to make the jump to 64-bit, you need to at least add a '?' somewhere in your post.
For starters, you might want to replace the 32-bit C kernel with a simpler, 32-bit ASM bootstrap. (As sortie's OS does)
The bootstrap has to...
1. Set up the PML4, PDPT, PD and PTs. (Don't enable paging)
2. Decide if your kernel will be higher or lower half. Map the memory accordingly.
3. Enable the LM bit, PAE bit and Paging bit at the same time. This will put you in compatibility mode.
4. Load a 64-bit GDT, and jump to a 64-bit code segment.
5. Mission accomplished. Long mode, activate!
You might want to read 'THE WIKI' for more information. In fact, that is what you should have done in the first place.
[nx] kernel: http://github.com/zhiayang/nx
Re: move to 64 bit OS
hm I need an example, my bochs machine is triple faulting all the time. I need it in AT&T assembly, not in Intel assembly, because I am using gas. Thank you
Re: move to 64 bit OS
If the GDT doesn't need to be above 4G, there is no need to load a 64-bit GDT.requimrar wrote: 4. Load a 64-bit GDT, and jump to a 64-bit code segment.
Re: move to 64 bit OS
Chapter 14 of Volume 2 of the AMD Programmers Manual gives full instructions, including a well-commented example, of switching to long mode.
As for assembler syntax - learn to use both; the differences are easy enough to grasp.
As for assembler syntax - learn to use both; the differences are easy enough to grasp.
Re: move to 64 bit OS
1. I don't mean to sound rude, but asking for code usually doesn't do you well.teodori wrote:hm I need an example, my bochs machine is triple faulting all the time. I need it in AT&T assembly, not in Intel assembly, because I am using gas. Thank you
2. Demands such as 'GNU syntax, not Intel syntax' also serve to annoy people.
3. Phrases such as 'I want' and 'I need' are not nice either.
Also, more information other than 'triple faulting all the time' is required for proper debugging. Set bochs *not* to reset on fault, and tell us what the ISR is. GPF probably means you're overwriting your own code or something, while PF usually means you didn't identity map (or failed to do properly) your kernel.
Code: Select all
// Enable PAE Paging
mov %cr4, %eax
orl $0x20, %eax // Set PAE Bit
mov %eax, %cr4
// Enable Long Mode
mov $0xC0000080, %ecx
rdmsr
orl $0x100, %eax
wrmsr
// Enable Paging, enter compatibility mode
mov %cr0, %eax
orl $0x80000000, %eax
mov %eax, %cr0
// Load Long Mode GDT
mov GDT64Pointer, %eax
lgdtl GDT64Pointer
[nx] kernel: http://github.com/zhiayang/nx
Re: move to 64 bit OS
Hello,
hm could anyone tell me how to setup those page tables please?
hm could anyone tell me how to setup those page tables please?
- Griwes
- Member
- Posts: 374
- Joined: Sat Jul 30, 2011 10:07 am
- Libera.chat IRC: Griwes
- Location: Wrocław/Racibórz, Poland
- Contact:
Re: move to 64 bit OS
RTFM.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations