Can GRUB module files be used for custom pre OS BIOS tasks?

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
bbrar
Posts: 5
Joined: Tue Jun 12, 2012 11:39 am

Can GRUB module files be used for custom pre OS BIOS tasks?

Post by bbrar »

I'm not very familiar with GRUB. But I'm researching the use of GRUB bootloader to launch and execute some pre OS operations ( like modifying bus enumeration/ access to PCI config space ). Can GRUB's module files be used for that? After the operations are performed , I would then launch /boot into the OS.
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: Can GRUB module files be used for custom pre OS BIOS tas

Post by Kazinsal »

bbrar wrote:I'm not very familiar with GRUB. But I'm researching the use of GRUB bootloader to launch and execute some pre OS operations ( like modifying bus enumeration/ access to PCI config space ). Can GRUB's module files be used for that? After the operations are performed , I would then launch /boot into the OS.
Assuming you mean modules executing in real mode before the kernel, no. GRUB will always jump to the kernel. Modules that are loaded are passed via structs to the kernel in the multiboot struct. So the modules are just extra files that GRUB loads for your kernel to use, and can be anything from an initrd to drivers to whatever you please.

Disclaimer: I don't claim to be a GRUB expert, just someone who's used it a couple of times.
User avatar
Combuster
Member
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:

Re: Can GRUB module files be used for custom pre OS BIOS tas

Post by Combuster »

bbrar wrote:I'm not very familiar with GRUB. But I'm researching the use of GRUB bootloader to launch and execute some pre OS operations ( like modifying bus enumeration/ access to PCI config space ). Can GRUB's module files be used for that? After the operations are performed , I would then launch /boot into the OS.
In practice, does it matter? The problem as described is nothing more than having several bits of code you want to run in a specific order. What is preventing you to just put those bits in the kernel binary and call the functions in that specific order?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
bbrar
Posts: 5
Joined: Tue Jun 12, 2012 11:39 am

Re: Can GRUB module files be used for custom pre OS BIOS tas

Post by bbrar »

Well.. ideally I want the code to be OS agnostic or in other words not plug into a specific OS.. that is why I am looking at doing my custom code prior to the OS booting up.
User avatar
Combuster
Member
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:

Re: Can GRUB module files be used for custom pre OS BIOS tas

Post by Combuster »

Unless you want to make a full-fledged virtualisation rootkit, there's nothing of the sort you can sanely do. Any OS started afterwards will simply enumerate the PCI of its own again and the only way you can alter the result is by preventing the access altogether. And in general, the only thing your code can really do - without having a way of communicating with the kernel - is breaking things.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply