general-usage real-mode loader
Hello. A long time ago I written a C+asm code which loads any given code at any real-mode location, then puts machine in correct state and then launches the kernel. I can modify this code to suit GRUB2. Then loading realmode kernel would work like this:
1) copy helper asm to last kb of lower memory
2) jump to the helper
3) helper copies from upper memory the kernel
4) turn A10 bug back on if necessary
5) go to RM
6) prepare registers
7) jump to the kernel
This protocol is very flexible and as such could be used by all loaders which load kernel in realmode or even in PM (skip step 5, do steps 6-7 in 32-bit mode) except for changing page tables. Such a helper can be easily implemented as module and so help us removing asm-parts of loaders from the kernel. If I recieve greenlight for it, I implement it. Vladimir 'phcoder' Serbinenko
BTW. This helper would allow easy addition of many different kernels (freedos, haiku, ntldr, ...)
Vladimir 'phcoder' Serbinenko
Quoted 18 lines · phcoder
Hello. A long time ago I written a C+asm code which loads any given code at any real-mode location, then puts machine in correct state and then launches the kernel. I can modify this code to suit GRUB2. Then loading realmode kernel would work like this:
1) copy helper asm to last kb of lower memory
2) jump to the helper
3) helper copies from upper memory the kernel
4) turn A10 bug back on if necessary
5) go to RM
6) prepare registers
7) jump to the kernelThis protocol is very flexible and as such could be used by all loaders which load kernel in realmode or even in PM (skip step 5, do steps 6-7 in 32-bit mode) except for changing page tables. Such a helper can be easily implemented as module and so help us removing asm-parts of loaders from the kernel. If I recieve greenlight for it, I implement it. Vladimir 'phcoder' Serbinenko
Quoted 12 lines · phcoder
Hello. A long time ago I written a C+asm code which loads any given code at any real-mode location, then puts machine in correct state and then launches the kernel. I can modify this code to suit GRUB2. Then loading realmode kernel would work like this:
1) copy helper asm to last kb of lower memory
2) jump to the helper
3) helper copies from upper memory the kernel
4) turn A10 bug back on if necessary
5) go to RM
6) prepare registers
7) jump to the kernel
Quoted 5 lines
This protocol is very flexible and as such could be used by all loaders which load kernel in realmode or even in PM (skip step 5, do steps 6-7 in 32-bit mode) except for changing page tables. Such a helper can be easily implemented as module and so help us removing asm-parts of loaders from the kernel. If I recieve greenlight for it, I implement it.
Maybe I'm confusing this with something else, but isn't this what both Bean and Vesa implemented separately, and are currently discussing in another thread?
(the goal there was to move BIOS wrappers out of kern/i386/pc/startup.S)
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
I checked the archive found the thread "Idea: Move kernel to upper memory". But what is discussed there is much more general about general memory layout. Here I wanted to speak about just one function. Vladimir 'phcoder' Serbinenko
Quoted 25 lines · Robert Millan
Quoted 12 lines · phcoder
Hello. A long time ago I written a C+asm code which loads any given code at any real-mode location, then puts machine in correct state and then launches the kernel. I can modify this code to suit GRUB2. Then loading realmode kernel would work like this:
1) copy helper asm to last kb of lower memory
2) jump to the helper
3) helper copies from upper memory the kernel
4) turn A10 bug back on if necessary
5) go to RM
6) prepare registers
7) jump to the kernelQuoted 5 lines
This protocol is very flexible and as such could be used by all loaders which load kernel in realmode or even in PM (skip step 5, do steps 6-7 in 32-bit mode) except for changing page tables. Such a helper can be easily implemented as module and so help us removing asm-parts of loaders from the kernel. If I recieve greenlight for it, I implement it.
Maybe I'm confusing this with something else, but isn't this what both Bean and Vesa implemented separately, and are currently discussing in another thread?
(the goal there was to move BIOS wrappers out of
kern/i386/pc/startup.S)
Quoted 4 lines · phcoder
I checked the archive found the thread "Idea: Move kernel to upper memory". But what is discussed there is much more general about general memory layout. Here I wanted to speak about just one function. Vladimir 'phcoder' Serbinenko
Try: [PATCH] Move assembly code out of the kernel
Well sometimes it's similar but most of the time isn't because your code runs a code in RM but with hope returning back to PM and normal grub operation. And it also loads to quite fixed place. My code would load a kernel, that means that it will not return and so code can be loaded to any place not needed by kernel.
Vladimir 'phcoder' Serbinenko
Quoted 13 lines · Vesa Jääskeläinen
Quoted 4 lines · phcoder
I checked the archive found the thread "Idea: Move kernel to upper memory". But what is discussed there is much more general about general memory layout. Here I wanted to speak about just one function. Vladimir 'phcoder' Serbinenko
Try: [PATCH] Move assembly code out of the kernel
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 5 lines · phcoder
Well sometimes it's similar but most of the time isn't because your code runs a code in RM but with hope returning back to PM and normal grub operation. And it also loads to quite fixed place. My code would load a kernel, that means that it will not return and so code can be loaded to any place not needed by kernel.
Do you mind replying inline...?
It is true that code is withing grub's i386 kernel. But other than that same mechanism can be used to load kernel. After all kernel will take over the computer after it has started and it is not returning back anymore (eg. stack is not anymore there to be restored).
I would prefer that if we are going to give custom register configurations for kernel then they all should use same structures for storing registers.
But anyway... Did you have some good examples where this functionaly would be needed :) ? For now we have specialized loaders that prepare system for any special OSes that needs to be supported. Especially how do you know what registers to fill or better yet, how user will provide this information so OS can be loaded.
If there is a need for specialized loader please provide some details where those are needed and what is required from GRUB in order to support that. If there is possibility to use multiboot then that would supersede need for specialized loader.
Thanks,
Vesa Jääskeläinen
Quoted 5 lines · Vesa Jääskeläinen
It is true that code is withing grub's i386 kernel. But other than that same mechanism can be used to load kernel. After all kernel will take over the computer after it has started and it is not returning back anymore (eg. stack is not anymore there to be restored).
In this case my rmkern helper can use this mechanism but the problem is then that the rmkern should be able to choose where to put RM helper since some OS need specific places in memory to be filled with specific values
Quoted 9 lines
I would prefer that if we are going to give custom register configurations for kernel then they all should use same structures for storing registers.
But anyway... Did you have some good examples where this functionaly would be needed :) ? For now we have specialized loaders that prepare system for any special OSes that needs to be supported. Especially how do you know what registers to fill or better yet, how user will provide this information so OS can be loaded.
I thought that this function can be used as general helper for any kernel that needs to be launched in RM. In that cases RMkern functionality is used by OS-specific wrapper which knows what to put in the registers
Usage cases:
1) chainloader
2) zbeos: BeOS and haiku. BeOS has a good functionality for booting from loopback but for this you need floppy, windows 9x/me or dos. On my laptop I have neither. But zbeos (BeOS and Haiku middle-loader) is really easy to load.
3) ecomstation: eCS is able to load from JFS but needs a specialized loader to be installed on its own primary active partition. I think GRUB should be able to load it directly. But perhaps also exporting of GRUB functions to ecomstation is needed (this is discussed in another thread, I'll write there later)
4) DOS/Win9x and freedos. Especially the second one. They use extended chainloader functionality found in grub4dos. With rmkern loading freedos kernel should be really easy.
5) Loading winnt (ntldr) and winvista (bootmgr)
6) Many other different proprietary and free OS. I don't know enough about them to say that this or that one can benefit from it but suppose many OS can be booted easier and more reliable with this functionality.
7) rmkern command. Experienced users, hobbysts and OS-developpers can enter manually the state in which they want their kernel to be loaded. May be handy also for reverse engineering
Quoted 5 lines
If there is a need for specialized loader please provide some details where those are needed and what is required from GRUB in order to support that. If there is possibility to use multiboot then that would supersede need for specialized loader.
Some OS have their reasons not to support multiboot. E.g. haiku and freedos stick very near to their goal of reimplementation beos/dos and as such they don't want anything that would be better
Vladimir 'phcoder' Serbinenko
Quoted 3 lines · phcoder
4) DOS/Win9x and freedos. Especially the second one. They use extended chainloader functionality found in grub4dos. With rmkern loading freedos kernel should be really easy.
Since FreeDOS is free software, we could fix it to use Multiboot instead.
Quoted 1 line
5) Loading winnt (ntldr) and winvista (bootmgr)
Ah, and there's a free replacement for NTLDR as well, see:
http://www.reactos.org/wiki/index.php/FreeLoader
Quoted 6 lines
6) Many other different proprietary and free OS. I don't know enough about them to say that this or that one can benefit from it but suppose many OS can be booted easier and more reliable with this functionality.
7) rmkern command. Experienced users, hobbysts and OS-developpers can enter manually the state in which they want their kernel to be loaded. May be handy also for reverse engineering
I think people (specially OS developers) should contemplate obsoleting the i8086 someday...
Some of the examples you give are things we should indeed support (most specially the chainloader), but I'm not sure if it's worthy to spend so much effort in extending them. IMHO we should push for a sane standard like Multiboot instead.
But I can't tell you what to do with your time, of course...
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."