Page 1 of 1

Multiboot CMD line

Posted: Thu Jan 10, 2013 5:09 pm
by jammmie999
Hey guys,

Any ideas how would be best to reboot a system, and inject a multiboot cmd line argument for GRUB to pass back to the OS after the reboot?

I am trying to implement a 'safe' mode, so when the OS boots, if there is a problem with a driver it will ask GRUB to give it the "safe mode" command line argument on the next boot, and restart the system. Upon rebooting the OS detects the safe mode argument, and doesn't run the device enumeration code.

I believe that multiboot is one-way communication only, so is this even possible? How else could I attain similar? I don't have any file system support yet, so writing a text file, and reading upon boot isn't really an option.

Thanks.

P.S. Do any of you use multiboots cmd line option for anything interesting?

Re: Multiboot CMD line

Posted: Thu Jan 10, 2013 5:34 pm
by sortie
The best way would be to simply change the GRUB bootloader configuration file. However, since you don't have filesystem support, I don't see a clean way. You could, as a work around, simply add two menu entries to GRUB and let the user select whether normal or safe mode is used.

Although, if you are yet to add filesystem support, I don't see that much use for a safe mode.

Re: Multiboot CMD line

Posted: Fri Jan 11, 2013 6:55 am
by bluemoon
IMO getting GRUB involved to your OS logic(ie. safe mode) is the wrong direction.

Even you don't have full file system support yet, you could write some data into the super-block (e.g. define a mount flag in the boot record or special sectors)

Re: Multiboot CMD line

Posted: Fri Jan 11, 2013 8:15 am
by rdos
I have a safe-mode in both my native boot and in GRUB boot. I solve it by having a known-valid binary image which can be booted + an image for test. In GRUB, I create two different entries, one for test and one for safe mode. I copy the current test image to safe regulary as I've tested a specific configuration so that safe-mode is somewhat up-to-date.

Re: Multiboot CMD line

Posted: Fri Jan 11, 2013 8:46 am
by AJ
Hi,

Before you have disk IO build in to your OS, I would question the usefulness of having a safe mode. Your OS is unlikely to have a "release" version and is therefore always likely to boot in debug mode at this stage anyway.

Once you do have disk and file IO, I'd just place a marker on the boot partition. If your OS crashes before it has boot partition access, chances are probably that a safe mode isn't going to achieve anything useful anyway. Where a safe mode becomes more useful is when the OS can get to a stage where disk IO is working, but when one of your other drivers or applications has caused a problem.

Cheers,
Adam