Yeah that sounds good, what do you use to compile the C file? Thanks.nexos wrote:How I plan on doing it is kind of complex, but here we go. The MBR code loads up stage 2. Stage 2 is two files concatenated with the cat command. The first one enters Protected Mode, and enables A20. It also relocates the second one, which is directly after. It then jumps to it. It is a C executable. When calling the BIOS, it will drop to real mode and call it, and then bounce back to PMode. Disk buffers will be put in a low memory temporary buffer, and then copied to the permanent buffer, which can be anywhere. Hopefully that makes sense and is of help.
Bootloader design
Re: Bootloader design
Re: Bootloader design
My OS is more Windows like, so MinGW for Linux, and it loads a PE. You could use a GCC cross compiler and load an ELF, or you could output a flat binary or MZ with Smaller C.
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: Bootloader design
One thing I will suggest is that you need to think beyond just the bootloader itself, and consider how you are going to install the loader onto a given system (even if it is just a disk image for a VM). Especially if you intend to make your system installable onto different media, or onto systems which use UEFI. A good OS installer is in some ways as much a code generator and editor as it is an image writer.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Re: Bootloader design
I don't understand this.Schol-R-LEA wrote:One thing I will suggest is that you need to think beyond just the bootloader itself, and consider how you are going to install the loader onto a given system (even if it is just a disk image for a VM). Especially if you intend to make your system installable onto different media, or onto systems which use UEFI. A good OS installer is in some ways as much a code generator and editor as it is an image writer.
Can't you just copy stage2 and the kernel to /boot/efi/ (or /boot/ or whatever your Linux distro uses to mount the ESP)? And doesn't Windows allow the user to copy files to the ESP?
And why is the installer a generator? An editor?
Greetings
Peter
Re: Bootloader design
Me neither, but I might have a clue what he could meant.PeterX wrote:I don't understand this.
Yes, if your loader is smart enough. But there are other things, like being multiplatform or userland for example to beconsidered. How will you create a partition for those data in the first place? How would you access those? For a kernel that's fine to copy to ESP, but you can't put everything on the ESP (well, you can, but you probably shouldn't). If your OS uses ext2, then how would you use it under Win? These are not unsolvable problems, but definitely things to be sorted out.PeterX wrote:Can't you just copy stage2 and the kernel to /boot/efi/ (or /boot/ or whatever your Linux distro uses to mount the ESP)? And doesn't Windows allow the user to copy files to the ESP?
I believe what he meant is, you'll never need all the things all the time. For example there's no point in putting the AArch64 version of "ls" into an x86-only bootable image.PeterX wrote:And why is the installer a generator? An editor?
Cheers,
bzt
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: Bootloader design
I had something a bit more immediate in mind: a first-stage boot loader designed for a BIOS system loading from a floppy will be different from one loading from a fixed drive, which in turn would differ from one booting from an El Torito CD (despite the latter's emulation functions). A BIOS system boots in a different way from a UEFI system, which realistically doesn't really need a first-stage loader at all in most cases, but does have its own way of interfacing with the kernel which the kernel needs to know about and handle sensibly. That sort of thing.
There's also the matter of tuning the boot process for the existing hardware, though that can be an open-ended sink for time and effort.
I'll admit that this is something of a gripe I have with a lot of loader designs, in that they stick to something very generic and as a result under-perform for most hardware. But then, I also favor source-based package management (in principle) for much the same reason, despite the fact that none of the existing ones are really usable (which is why I switched from Gentoo to Manjaro for my preferred Linux distro), so perhaps I am the crazy one here (I mean, I am crazy anyway, but... you know what I mean).
There's also the matter of tuning the boot process for the existing hardware, though that can be an open-ended sink for time and effort.
I'll admit that this is something of a gripe I have with a lot of loader designs, in that they stick to something very generic and as a result under-perform for most hardware. But then, I also favor source-based package management (in principle) for much the same reason, despite the fact that none of the existing ones are really usable (which is why I switched from Gentoo to Manjaro for my preferred Linux distro), so perhaps I am the crazy one here (I mean, I am crazy anyway, but... you know what I mean).
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Re: Bootloader design
Ok, maybe for floppies, but if you move them out of the equation to solely rely on LBA, all the rest can use the same boot record (see my bootloader's boot.asm).Schol-R-LEA wrote:I had something a bit more immediate in mind: a first-stage boot loader designed for a BIOS system loading from a floppy will be different from one loading from a fixed drive, which in turn would differ from one booting from an El Torito CD
First part is true, but the second isn't. You can write a bunch of bootloaders in a way that they interface with the kernel exactly the same way, therefore the kernel doesn't need to know about the firmware at all. Actually that's the whole point of BOOTBOOT Protocol. Write your kernel once, and don't care on which platform it's booted on and how. (Being binary compatible on platforms with the same CPU, and source compatible for platforms with different CPUs.)Schol-R-LEA wrote:A BIOS system boots in a different way from a UEFI system, which realistically doesn't really need a first-stage loader at all in most cases, but does have its own way of interfacing with the kernel which the kernel needs to know about and handle sensibly. That sort of thing.
Nope, I totally agree with you. And I also had to gave up on Gentoo, a change in emerge created a circular dependency hell with fast Furier transformation library. And I said: a) why on earth does a package manager need fast Furier transform in the first place? b) if I have to reinstall my entire system because of this stupid issue, do I really want to go with Gentoo again? Which is sad, because when there was no issues with emerge I really really liked that distro. It was comfortable (for me) and everything run lightning fast, perfectly tuned to my computer. Booted in less than a sec from turn on to X11 logon Do that with Bugbuntu!Schol-R-LEA wrote:I also favor source-based package management (in principle) for much the same reason, despite the fact that none of the existing ones are really usable (which is why I switched from Gentoo to Manjaro for my preferred Linux distro), so perhaps I am the crazy one here (I mean, I am crazy anyway, but... you know what I mean).
Cheers,
bzt
-
- Member
- Posts: 5512
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Bootloader design
Floppy and hard drive bootloaders will be different, but El Torito emulation allows you to use both unmodified (provided they use BIOS calls to access the disk). I wouldn't say it's a good idea, but it will work.Schol-R-LEA wrote:I had something a bit more immediate in mind: a first-stage boot loader designed for a BIOS system loading from a floppy will be different from one loading from a fixed drive, which in turn would differ from one booting from an El Torito CD (despite the latter's emulation functions).
What exactly do you have in mind here?Schol-R-LEA wrote:There's also the matter of tuning the boot process for the existing hardware, though that can be an open-ended sink for time and effort.
I'll admit that this is something of a gripe I have with a lot of loader designs, in that they stick to something very generic and as a result under-perform for most hardware.