Grub - loading more files

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Code

Grub - loading more files

Post by Code »

Hello, is it possible that grub loads the kernel and some other files, like drivers ?
And another question: IS grub able to change into vesa ?
If yes, how ?
AR

Re:Grub - loading more files

Post by AR »

GRUB has a section in the Multiboot header for requesting graphical modes, I don't know whether it actually works though.

Use the module command to load additional files:

Code: Select all

title My Operating System
kernel /MyOS/Kernel.elf
module /MyOS/Config.gzip
module /MyOS/Drivers.img.gzip
module /MyOS/Boot.ini
Code

Re:Grub - loading more files

Post by Code »

Hello, if i use the module command where are the files loaded ?
Is it possible to say that Boot.ini will be loaded at 0x200000 ?
AR

Re:Grub - loading more files

Post by AR »

The files are loaded directly after the kernel (you can set a multiboot flag to align them to the 4KB Physical Pages if you need), unfortunately the locations are not configurable, you will have to relocate them manually.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Grub - loading more files

Post by Pype.Clicker »

the thing is that GRUB loads *files*, not *modules* in the sense of Linux Kernel Modules. It doesn't know anything of what you might want to do with those files. It might be a splash screen, a "setup" program, a device driver, or whatever.

It will be up to your kernel to browse the multiboot information structure passed by GRUB and learn where those files have been placed, then do whatever you want with them (like reading symbols, relocating code, resolving dependencies, calling init functions and the like)
AR

Re:Grub - loading more files

Post by AR »

I should probably mention, since few people seem to know, that GRUB automatically decompresses GZIPed modules, you are welcome to compress modules (you can compress the kernel image as well) and GRUB will decompress them in memory [so the GZIPed files in my example would be autoexpanded for you].
mystran

Re:Grub - loading more files

Post by mystran »

Personally, I use the "modules" to load the first few "userspace" programs. Since I have a microkernel, which has no means to load anything itself, multiboot modules provide a nice, simple way to load enough stuff to get the system up and running.

My current plan is actually to load each module as a userspace process. Normally one will need just two: the initial ramdisk, with the relevant code to startup other services, and a device manager. But you could startup several "independent" systems, by using two ramdisks (although you still want only one device manager, because having two sets of device drivers won't result in anything sane).

Other systems use other solutions. I believe some version of Hurd (the L4 port?) actually loads a special startup-program as it's "kernel" image, and has the real kernel as a module.

Or you could have a plain-text configuration file of what drivers to load, and what programs to start. I believe QNX has something like this (although I can't remember whether it supports multiboot).
Tora OS

Re:Grub - loading more files

Post by Tora OS »

an alternate question relating to the GZIP thing:


Is it possible to compress your kernel too or just the modules?
pini

Re:Grub - loading more files

Post by pini »

The kernel can be compressed too.
Post Reply