x86-64 kernel
x86-64 kernel
hi,
i want to develop kernel for x86-64 arch. Since initially GRUB loads kernel in 32bits protected mode,first part of my kernel has to be 32bit and then when i activate Long Mode, whatever instructions i execute have to be of 64bit kernel. So what i need is combination of 32bit and 64bit kernel.
So is it possible that i compile 32bit and 64bit kernel seperately and then link them together to form final kernel??
Considering i am using gcc , in what format should i compile my 64bit kernel in? i use elf32 format for my 32bit kernel part.
Secondly i don't want that , there should be two separate 32bit and 64bit kernel , in which case initial 32bit kernel loads 64bit kernel part after activating Long Mode. Because then i will have to write HDD,FDD,DMA drivers and etc unwanted stuff at initial stage! Coz drivers i write for 32bit kernel won't be usable for my 64bit kernel which is the real kernel part i am interested in.
Any Suggestions?? are most Welcomed!
i want to develop kernel for x86-64 arch. Since initially GRUB loads kernel in 32bits protected mode,first part of my kernel has to be 32bit and then when i activate Long Mode, whatever instructions i execute have to be of 64bit kernel. So what i need is combination of 32bit and 64bit kernel.
So is it possible that i compile 32bit and 64bit kernel seperately and then link them together to form final kernel??
Considering i am using gcc , in what format should i compile my 64bit kernel in? i use elf32 format for my 32bit kernel part.
Secondly i don't want that , there should be two separate 32bit and 64bit kernel , in which case initial 32bit kernel loads 64bit kernel part after activating Long Mode. Because then i will have to write HDD,FDD,DMA drivers and etc unwanted stuff at initial stage! Coz drivers i write for 32bit kernel won't be usable for my 64bit kernel which is the real kernel part i am interested in.
Any Suggestions?? are most Welcomed!
Nothings Impossible
-
- Member
- Posts: 31
- Joined: Sun Jun 26, 2005 11:00 pm
- Location: Toronto, Ontario, Canada
- Contact:
Re: x86-64 kernel
Well, you could just write your own BootLoader, I find that it helped me get exactly what I wanted during my BIOS enabled stage .
Then again, I really do not know much about 64bit development, I am stuck in 32 bit land still. Well, its just an idea and you will probly get to learn a lot more writing your own start up.
Then again, I really do not know much about 64bit development, I am stuck in 32 bit land still. Well, its just an idea and you will probly get to learn a lot more writing your own start up.
It will come from the ashes of the old era.
-- James Vaughan
-- James Vaughan
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: x86-64 kernel
GRUB supports the loading of modules. Basically, that means that it will load some specified files into memory before transferring control to your kernel. What I might suggest is that the "kernel" that you have GRUB load could just be a 32-bit loader which sets up long mode, and then have the real kernel loaded into memory as a module by GRUB, and have your 32-bit loader load it into the correct location in memory and start it.kan wrote:Any Suggestions?? are most Welcomed!
This is definitely harder than using GRUB in 32-bit mode, but it's still easier than writing a bootloader to support everything that GRUB does.
-
- Member
- Posts: 31
- Joined: Sun Jun 26, 2005 11:00 pm
- Location: Toronto, Ontario, Canada
- Contact:
Re: x86-64 kernel
Very true, but I assume that this will be the first attempt at developing a kernel, so a good hard bootloader lession might be a good one to start with. And I am sure that most of the advanced features of GRUB won't be needed for a reletivly long time.
It will come from the ashes of the old era.
-- James Vaughan
-- James Vaughan
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: x86-64 kernel
I don't see the point in that. Most of the things you need to do in a bootloader you also need to do in your OS, so even if you are looking for a learning experience, the OS should be plenty.Phibred wrote:Very true, but I assume that this will be the first attempt at developing a kernel, so a good hard bootloader lession might be a good one to start with.
That depends. If you are writing a microkernel with no hardware drivers built-in, the module loading capability may be essential nearly from day one. It's also easier to debug just your kernel, and not have to worry that the bootloader may do strange things and need a lot of additional debugging as well. And it's always nice to be able to load from a filesystem easily, especially if you already have OSes installed on your computer.Phibred wrote:And I am sure that most of the advanced features of GRUB won't be needed for a reletivly long time.
Re: x86-64 kernel
hi,
hmmm,thank u for ur suggestions. i think a better approach would be to load 32bit kernel normally and 64bit kernel as module with help of GRUB.
But my main question is left unanswered! i.e Can we combine both 32bit and 64bit kernel together? and secondly can i compile and link 64bit kernel using existing file formats such as elf32 ...etc??????
I hope these questions get answered soon
hmmm,thank u for ur suggestions. i think a better approach would be to load 32bit kernel normally and 64bit kernel as module with help of GRUB.
But my main question is left unanswered! i.e Can we combine both 32bit and 64bit kernel together? and secondly can i compile and link 64bit kernel using existing file formats such as elf32 ...etc??????
I hope these questions get answered soon
Nothings Impossible
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: x86-64 kernel
You can combine anything you want in an OS image... you could include a JPEG and a text file, if you wanted, it's your call. It's entirely possible to combine a 32-bit image and a 64-bit image together, you'll just have to make sure that the processor is in the right mode to execute the appropriate sections (several kernels in the past have done this with combined 16 and 32-bit images).
As per existing file formats... no, you can't use elf32. How would you represent a 64-bit offset with a 32-bit object format? You'll need elf64 tools.
Also, with all this talk of loading a stub via grub and the actual kernel as a module... why not just combine your stub into grub. In other words, update grub such that it puts the processor into long mode, then there's no need for work-arounds such as this.
--Jeff
As per existing file formats... no, you can't use elf32. How would you represent a 64-bit offset with a 32-bit object format? You'll need elf64 tools.
Also, with all this talk of loading a stub via grub and the actual kernel as a module... why not just combine your stub into grub. In other words, update grub such that it puts the processor into long mode, then there's no need for work-arounds such as this.
--Jeff
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: x86-64 kernel
True, a patch to get GRUB to support 64-bit kernels would be the cleanest solution. And I suppose it could be back-compatible. When loading elf32, set protected mode for a 32-bit kernel, when loading elf64, use long mode. Actually, it would be nice if GRUB would adopt an official patch for this.carbonBased wrote:Also, with all this talk of loading a stub via grub and the actual kernel as a module... why not just combine your stub into grub. In other words, update grub such that it puts the processor into long mode, then there's no need for work-arounds such as this.
Re: x86-64 kernel
thank u all, for ur suggestions. OS development is a really complicated process, though an interesting one!
Nothings Impossible