3

I am writing my own bootloader and would like to make it possible to chainload it using grub2.

  • In which registers does grub pass the drive number and the partition entry point?
  • Is there a specification in which registers they should regularely be passed?
  • Can I make grub use registers of my choice?

Update:
In the grub legacy manual for the 'root' command it says that ES:ESI are used. During my research I found out that normally DL:SI should be used. (Grub MBR does that itself, as pointed out in the comments). Grub2 manual doesn't say anything about that. So, any ideas why grub legacy uses ES:ESI instead of DL:SI and what does grub2 actually use?

Zulakis
  • 7,859
  • 10
  • 42
  • 67
  • 1
    Unless you want to explicitly use grub2 chainloading, I'd recommend using the multiboot specification (http://wiki.osdev.org/Multiboot) – Drew McGowen Jul 08 '13 at 16:01
  • Thanks for the comment, however I am asking this for a stage 1 bootloader and the multiboot headers sadly won't fit into that. For stage 2 bootloaders, this is of course right. – Zulakis Jul 08 '13 at 18:06
  • So you're basically looking for code that can be both directly run by BIOS and from GRUB? – Drew McGowen Jul 08 '13 at 21:32
  • It needs to be runnable by a stage 0 (->mbr) bootloader and grub. The difference between that and being runnable by BIOS is that it already knows which partition it's going to use to boot. – Zulakis Jul 08 '13 at 21:37
  • I did the same thing for MirBSD, but I decided I can skip the “stage1” when chainloading from GRUB and use “stage2” directly. I also went the Multiboot route. My code then saves the information GRUB passes, jumps back to Real Mode, and proceeds as if it were called by my own “stage1” in Real Mode, except the drive information is kept. A “stage1” is only passed the drive number (in DL) on entry, nothing about partitions – this holds true for BIOS, too, though. – mirabilos Dec 06 '13 at 20:31

0 Answers0