1

So, I have a protected mode (32-bit, x86) assembly program that is loaded by GRUB2. It is multiboot-compatible. This program is just intended to be a game, not an operating system. Therefore I would like to use GRUB as a kind of program switcher.

Jumping back to 0x7C00 would obviously not work, because by the time my kernel is loaded the CPU is already in Protected Mode, and 0x7C00 is the entry point for real mode boot-sectors. So, where is the GRUB2 stage 2 bootloader loaded by stage 1? Does it get erased, assuming my program does not? Also, are there any other problems with simply jumping to the bootloader?

I want to do this without either switching to real mode or rebooting the machine.

sadljkfhalskdjfh
  • 747
  • 3
  • 10
  • 17
  • Go back to real mode and FAR JMP to 0xF000:0xFFF0 and reboot the machine? – Michael Petch Oct 07 '15 at 15:46
  • @MichaelPetch I was thinking to do that without rebooting the machine, because on my macbook EFI booting is extremely slow for some reason. Also, I think that switching to real mode is a big hassle. I'll edit my question to be more specific. – sadljkfhalskdjfh Oct 07 '15 at 15:49
  • You could always write the value 0x1234 to the word @ address 0x0040:0x0072 and then do the `far jmp` mentioned to do a warm reboot skipping the POST initialization. Assuming you were willing to get out of protected mode and warm reboot. I see you updated your question as I type this. But I'll still leave the comment. – Michael Petch Oct 07 '15 at 15:54
  • 1
    Don't quote me on this but I don't think you can rely on GRUB/GRUB2 being in a state that can be restarted. I don't know of any project that is known to do as you ask. I have no reference material to back up my claim. If you wish to see a memory map for GRUB this page might help: http://gnu.huihoo.org/grub-0.90/html_chapter/grub_22.html – Michael Petch Oct 07 '15 at 16:07
  • 1
    I think you're going to have to do some sort of reboot. You might be able to get back to EFI and have it boot GRUB again. EFI is at least designed to allow being returned to, but I don't know if it can be returned to after GRUB has been booted. – Ross Ridge Oct 07 '15 at 16:16

0 Answers0