Anyone know if there is a tool for booting a multiboot image from within linux? Something like loadlin for dos...
-
Thomas
Booting multiboot image from within Linux
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Booting multiboot image from within Linux
Yes. It's called QEMU, or Bochs, or Virtual Box, or VMWare. or <Favorite virtualization software here> and Grub.
I mean, seriously, what do you expect it to do? Boot it in an emulator, or replace the running Linux instance with the OS?
In the case of the former... use an emulator. In the case of the latter, it's not happening - applications don't have the privileges required to replace the running kernel, and it's also a technical impossibility for them to do so reliably.
I mean, seriously, what do you expect it to do? Boot it in an emulator, or replace the running Linux instance with the OS?
In the case of the former... use an emulator. In the case of the latter, it's not happening - applications don't have the privileges required to replace the running kernel, and it's also a technical impossibility for them to do so reliably.
Re: Booting multiboot image from within Linux
Are you serious?
I need to boot my kernel (replace the running kernel)... Like Solaris does if you ask it to with the reboot option.
Linux have things like this for ARM etc but i cannot find anything for x86.
If you want understand you can read here; http://www.embeddedarm.com/software/arm ... loader.php
-
Thomas
I need to boot my kernel (replace the running kernel)... Like Solaris does if you ask it to with the reboot option.
Linux have things like this for ARM etc but i cannot find anything for x86.
If you want understand you can read here; http://www.embeddedarm.com/software/arm ... loader.php
-
Thomas
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Booting multiboot image from within Linux
... by jumping to a stub loaded in memory which brings down the kernel, unmaps it all, and then reloads it (iirc, been a while since I was at the seminar where it was explained in detail). To my understanding, you can't do that in userspace without specific kernel hooks... So unless you feel like modifying your Linux kernel, you will find it difficult to try this out. You are definitely better off just using an emulator, and it's faster to do that anyway.Like Solaris does if you ask it to with the reboot option.
Re: Booting multiboot image from within Linux
Well,
I use emulators like vmware and bochs for normal development cycle for my kernel, but i'm experimenting with something and i want to try it out;)
Seems that there are not anything made for x86 just for other more "embedded" architectures.
Im going to give it a shot myself. Should not be to hard actually;
1. Create a kernel module that reserves some physical memory when told to.
2. Userspace app that sends data to this buffer via the module.
3. Userspace app tells module to "boot"
4. kernel module disable all ints, etc, relocate code to where it was specified in multiboot info and then does a far jmp
-
Thomas
I use emulators like vmware and bochs for normal development cycle for my kernel, but i'm experimenting with something and i want to try it out;)
Seems that there are not anything made for x86 just for other more "embedded" architectures.
Im going to give it a shot myself. Should not be to hard actually;
1. Create a kernel module that reserves some physical memory when told to.
2. Userspace app that sends data to this buffer via the module.
3. Userspace app tells module to "boot"
4. kernel module disable all ints, etc, relocate code to where it was specified in multiboot info and then does a far jmp
-
Thomas
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Booting multiboot image from within Linux
Well, that seems to be the easiest way of doing it, but I suggest that you put some proper access controls on it. But, the reason loadlin exists for linux is that it was designed for machines that did not have a menu-based bootloader, so instead of installing LiLo or GrUB (did they even exist then?) you would use loadlin.
With modern machines it's just as easy to add your Multiboot kernel to the GrUB boot order and restart. In fact, it's even better, because doing it by just unloading the linux kernel and loading you own, quite likely linux will not be shut down properly and hence you could loose data. (Plus, linux might do things with hardware that requires special code to de- and re-init, making your OS run strangely
With modern machines it's just as easy to add your Multiboot kernel to the GrUB boot order and restart. In fact, it's even better, because doing it by just unloading the linux kernel and loading you own, quite likely linux will not be shut down properly and hence you could loose data. (Plus, linux might do things with hardware that requires special code to de- and re-init, making your OS run strangely
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Booting multiboot image from within Linux
If it has anything to do with physical hardware, some emulators allow the guest to directly access certain hardware devices. That might be an easier solution, but I don't know what you're trying to do.but i'm experimenting with something and i want to try it out
Re: Booting multiboot image from within Linux
Hmm,
First of all the linux kernel cannot do anything after i have releaved it from its duties so to speak. Off course drivers etc can have initialised both hardware dma, and all sorts of other stuff BUT as far as my Linux kernel knowledge go im pretty sure i can force Linux to do the following after i have loaded my image;
1. Stopp all kmodules (device drivers) except my bootloading module. That means all cleanup / shutdown will be called on all devices. Pretty mouch stopping everything including hardware dma etc.
2. When that is done i can stop/halt the kernel also and execute my code that i just moved to the desired address.
I think since this has been done on arm and other architectures it should be fairly possible on x86 aswell. Of course the bios data stuff etc must be considered lost, but besides that i would be able to boot my kernel.
I think...
First of all the linux kernel cannot do anything after i have releaved it from its duties so to speak. Off course drivers etc can have initialised both hardware dma, and all sorts of other stuff BUT as far as my Linux kernel knowledge go im pretty sure i can force Linux to do the following after i have loaded my image;
1. Stopp all kmodules (device drivers) except my bootloading module. That means all cleanup / shutdown will be called on all devices. Pretty mouch stopping everything including hardware dma etc.
2. When that is done i can stop/halt the kernel also and execute my code that i just moved to the desired address.
I think since this has been done on arm and other architectures it should be fairly possible on x86 aswell. Of course the bios data stuff etc must be considered lost, but besides that i would be able to boot my kernel.
I think...