Re: Generic bootloader
Posted: Thu Dec 06, 2012 1:59 am
Hi,
Regards,
Shikhin
That looks like a good design. I have a nearly similar design in mind, and I'll soon post it (in response to your latest post). Please don't mind my slow replies; I just realized how buggy real life is. And it triple faults every night.bluemoon wrote:The design I use (and probably quite common) have multiple stages for boot loader:
So, to support more FS you basically write different VBRs with the file loading API. You may also need to extend the stages to support different media source (BIOS HDD service, or PXE, or EFI) in similar manner.Code: Select all
0. standard MBR - Load 512 bytes VBR, this is independent to OS, and can be replaced by any other standard MBR 1. VBR - This is specific for each type of file system, ie. I have FAT16.asm for FAT16, FAT32.asm for FAT32 - This VBR provide the file loading API (at pre-defined entry point) to subsequent stages - This VBB then load /boot.bin from the file system 2. BOOT.BIN - Memory Map - Enable A20 - Detect CPU 3. I also built this into boot.bin - Load 32/64bit kernel and initrd - Setup consistent environment (CPU registers state, 32-bit protected mode without paging, or compatibility mode with identity mapped region, etc) - pass control to kernel
I'm pretty sure everyone would have a differing boot-loader design (mine would not work with a generic loader, either). That's good for those who really want fine-tune control over how their kernel is put in power. For others, a generic design can be very well made - and that's what I'm aiming at.rdos wrote:My boot-loader design is a little different.
While that would be neat if you'd have the entire hard disk at your leisure, but if the hard disk is already properly partitioned, then I guess that won't work properly (how would you gain the 14 sectors directly after the MBR without repartitioning, etc).rdos wrote:...loads 14 sectors directly after the MBR...
I'd go for support for multiple file systems (or a boot-loader which works with them all, without caring for a file system).rdos wrote:...a FAT file system...
For paging, it's more cleaner to have an option in the configuration file. The default would obviously be a flat 32-bit environment (without paging), and long-mode and 32-bit paging can just be optional add-ons.rdos wrote:As can be seen, this boot scenario cannot be supported by a generic boot-loader. If the boot-loader sets up paging, my interface will need to revert back to no paging and redo it from scratch. If it sets up a GDT or IDT, same thing, I'd have to replace those with my own GDT and IDT.
Hrm. The project would surely not become an OS implementation. For the latter, I'd leave you to judge for yourself (the design would soon follow... d'oh, said that again, but I'll just reply to the backlog before the last three posts).rdos wrote:If the plan is to provide most of the initialization parts of an OS, which in the end will be a highly comforming OS implementation since it is impossible to do this in a common way for widely divergent OSes, then, count my out. OTOH, if the project aims at supporting more than GCC cross-compiled OS-images that initialize some *nix environment, then maybe.
I'd surely not set-up identity-mapped paging. As for the place of the kernel, it can either be specified using the vaddr field in the ELF header (if the kernel's format is ELF), or in the config file if it's some other format.rdos wrote:Most OSes don't have memory identity-mapped after boot, so why do you want that setup? The place of the kernel also is very different between OSes and operating modes.
Regards,
Shikhin