On Sunday 20 July 2008 01:06:22 Robert Millan wrote: > Anyone recalls the reason our loaders had to jump back to kernel > (startup.S) to do the final part of the load?
Not all of them should do that, but it might be more convenient. I look at one by one: - The chainloader needs to get back the original state (e.g. A20 disabled), so the final code must be located at below 1MB. Since the address of the startup code is well known, it is easier to use. - The linux loader does not have to overwrite the startup code, but other regions can be. So it is easier to use. - The multiboot loader had, historically speaking, a limitation that it may not load an OS image below 1MB. So it was easier to use. But I don't remember if this limitation is still present in the current implementation. > IIRC this causes trouble when the loadee chose an address that precisely > overwrites the loader, which is garanteed to happen when GRUB is loading > itself, AFAICT. Sure. My recommendation is, in case where you might overwrite that part, that you should write relocatable code (which is rather easy for simple code on i386) at anywhere (it could be in the startup), find out a safe region when loading an OS image, copy the code to the safe region, and finalize the bootstrap in that code (e.g. relocating the OS image, initializing registers, and jumping to it). On i386, we have a reserved region to temporarily load an OS image for the very reason, so this is not difficult. Regards, Okuji _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel