Hi! I read the multiboot documentation, and I saw that it was possible for the bootloader to load boot modules in RAM for the kernel. Because I want to create a microkernel I find this awesome, I searched in the documentation of GRUB how it was possible to do that and I finally find the "module" command to load GRUB module in RAM for the kernel.
What I would like to do is to use a GRUB module to load the disk driver and process management program of my kernel, and then use them to load the rest. I was able to find the GRUB modules in RAM, but now I struggle on how to use them. They are a relocatable elf, so they need to be linked with something. Does this mean that I should know where the executable code of the core image of GRUB has been load in memory and write a small linker in my kernel? I think there is another way.
Does somebody know how to use GRUB modules as executable for the kernel? I can't find any info. Or maybe I can just call functions from the elf file of the GRUB module?
Using GRUB2 modules in the kernel
-
- Posts: 17
- Joined: Wed Feb 15, 2017 8:29 am
- Libera.chat IRC: DridriLaBastos
Re: Using GRUB2 modules in the kernel
"GRUB modules" are simply files that are loaded into memory and are pointed to by the "module" struct in the multiboot struct.
After they are loaded into memory they have nothing to do with GRUB whatsoever. So yes, you'll need to link the ELF executable to your kernel at runtime and jump to the entrypoint.
After they are loaded into memory they have nothing to do with GRUB whatsoever. So yes, you'll need to link the ELF executable to your kernel at runtime and jump to the entrypoint.
-
- Posts: 17
- Joined: Wed Feb 15, 2017 8:29 am
- Libera.chat IRC: DridriLaBastos
Re: Using GRUB2 modules in the kernel
Ok, so this means that if I want to use the GRUB module I have to embed the core image of GRUB into the kernel? I don't think it's a good solution (but I am curious to test it, it should be possible to have a small image with everything inside). The other option I see is to create something like ramfs.
Thanks for the reply
Thanks for the reply
Re: Using GRUB2 modules in the kernel
There is a difference between kernel modules loaded by GRUB (you control the contents entirely, GRUB only loads them from disk and passes a pointer to the module via the Multiboot info struct) and modules for GRUB (i.e., extensions of GRUB that are loaded/compiled into GRUB.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
-
- Posts: 17
- Joined: Wed Feb 15, 2017 8:29 am
- Libera.chat IRC: DridriLaBastos
Re: Using GRUB2 modules in the kernel
Oooh thank you, I thought it was only possible to load GRUB module with the command module, but I can load whatever file I want. This is exactly what I wanted, I am so happy right now !Korona wrote:There is a difference between kernel modules loaded by GRUB (you control the contents entirely, GRUB only loads them from disk and passes a pointer to the module via the Multiboot info struct) and modules for GRUB (i.e., extensions of GRUB that are loaded/compiled into GRUB.