Still very busy with my Phd thesis and my wedding, but i'm missing you, guys ... and i have to admit it, i'm missing those USB and graphic accelerants and ACPI/APIC too.
I cannot help wishing we had a cleaner beast than x86 to hack with, but well, the world is what it is, right ?
But back on topic. Iirc, there is atm. no such thing like a long-mode GRUB, is it? And there isn't anything like a x86-64 (long mode) barebone in the wiki.
So this is a call for participation. Who has been doing enough attempts with x86-64 and would be willing to give recommendation on how to setup a quick kernel that runs in long mode and that people could start using (i guess out of 32-bit GRUB) in a couple of hours if one has already written down another kernel?
And what would you have to share ?
BareBones64 ?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
I guess you could have grub load an elf32 stub which then switches to long mode and relocates an elf64 binary that is provided as a module.
Of course a grub which both switches to long mode for you and is able to relocate an elf64 binary might make a lot more sense, but then I suppose most people here are more interested in writing kernels than boot loaders.
Regards,
John.
Of course a grub which both switches to long mode for you and is able to relocate an elf64 binary might make a lot more sense, but then I suppose most people here are more interested in writing kernels than boot loaders.
Regards,
John.
Well I do that and it's around 600 lines of assembly code just for the loader, so it's nothing for a bare bones and the elf is not relocated at all, just the segments are loaded into memory...jnc100 wrote:I guess you could have grub load an elf32 stub which then switches to long mode and relocates an elf64 binary that is provided as a module.
The problem with switching to longmode is, that you have to enable paging and it would suck if grub did enable paging imho...Of course a grub which both switches to long mode for you and is able to relocate an elf64 binary might make a lot more sense, ...
edit: grub2 should be able to load elf64 files properly...
Sorry, meant load.bluecode wrote:just the segments are loaded into memory
Not wanting to get into a discussion on C vs asm, but that would be less in C and possibly more understandable for beginners (who I assume the bare bones tutorial is aimed at).bluecode wrote:it's around 600 lines of assembly code just for the loader
Grub sets up a gdt to enter pmode, what's wrong with it setting up a small paging setup that maps the kernel and multiboot header? You can always change it later (as we do with the gdt). The only extra information it would need to provide is which physical addresses have been assigned to the kernel etc, but with a bit more work you could even get these from the page tables.bluecode wrote:it would suck if grub did enable paging imho...
I suppose the physical memory manager (depending on your implementation) would be more difficult to set up with paging enabled, but not impossible. I'm sure if a ready-made long mode was provided by grub, it would be able to be switched on or off by a command line option. I presume we can all agree that having grub be able to parse elf64 would be a good thing, however?
By the way, there's a short discussion on the implementation of loading an elf64 OpenSolaris kernel in grub at http://www.opensolaris.org/jive/thread. ... 5&tstart=0
edit: Multiboot draft for grub2 http://grub.enbug.org/MultibootDraft
Regards,
John.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
I think you can just assemble a 32-bit loader stub to a 64-bit ELF object file format. You can put the initialisation code in there (enable longmode and paging then jump to the kernel entry point), then link all the files into a binary image. If you are good with position-independent code, you can write a higherhalf barebones pretty much the same way.
But then again, I never even managed to get PAE working so i might be missing some details.
$.02
But then again, I never even managed to get PAE working so i might be missing some details.
$.02
Re: BareBones64 ?
I have my own kernel which works on AMD64 plus a bootloader that works on *FS and that includes long mode booting support. I have an example hello world for long mode and my own kernel. The boot loader contains a simple file called "longmode.asm" that boots to longmode including setting up paging. The longmode kernel, sadly, crashes because of some complexity in getting paging right, but I'm working on that very recently (few days ago). There is a release of the bootloader, hello worlds and mkfs tool that together can make a working system, but it's incompatible in terms of paging setup with my kernel so it's an intermediate version. It's a "finished" version though, the three items are freely exchangeable.Pype.Clicker wrote:Still very busy with my Phd thesis and my wedding, but i'm missing you, guys ... and i have to admit it, i'm missing those USB and graphic accelerants and ACPI/APIC too.
I cannot help wishing we had a cleaner beast than x86 to hack with, but well, the world is what it is, right ?
But back on topic. Iirc, there is atm. no such thing like a long-mode GRUB, is it? And there isn't anything like a x86-64 (long mode) barebone in the wiki.
So this is a call for participation. Who has been doing enough attempts with x86-64 and would be willing to give recommendation on how to setup a quick kernel that runs in long mode and that people could start using (i guess out of 32-bit GRUB) in a couple of hours if one has already written down another kernel?
And what would you have to share ?
You can probably port most of the long mode code to Grub. As I believe in making all the base code public domain, this is too. You can download it from http://www.sf.net/projects/atlantisos - either the published version or the SVN version. The SVN version boots with a different setup and includes updated paging code in the C part of the bootloader.
I would definitely be interested in helping with a long mode barebones kernel. Grub2 isn't entirely stable, but it can load an elf64 file and set up long mode for you. Yes, this means enabling paging, but it's really not all that bad. I've got a hello world kernel in long mode already (using Grub2) that I would happily post to the wiki. Also, I'd be willing to help add elf64 support to Grub Legacy should anyone be interested in that.
-
- Posts: 13
- Joined: Sat Apr 28, 2007 1:57 am
There is patch that is supposed make grub legacy load elf64 images. You can find it here:quok wrote:Also, I'd be willing to help add elf64 support to Grub Legacy should anyone be interested in that.
http://savannah.gnu.org/bugs/?17963
I have never used it, so don't blame me if it doesn't work.
I currently use grub2 to load elf64 images and it seems to do ok, even though it's behavior is not as smooth as the next version of Multiboot Specification describes.
@quok
I would greatly appreciate it if you could give me your hello world kernel in long mode to experiment.