r/osdev • u/CtrlF0rge • 3d ago
Is the bootloader considered part of the system?
It says that I am building the operating system from scratch, but the bootloader is used limine to relieve me of the load of booting on 3 processor architectures
8
Upvotes
21
u/Dapper-Situation-864 3d ago •
Pretty much nobody counts the bootloader as "the OS" in that sense. Linux is booted by GRUB, systemd-boot, or the firmware's EFI stub, and nobody says Linux isn't written from scratch because of it. The bootloader's job ends once it has loaded your kernel, set up a sane CPU state, and handed over a memory map. Everything after that (memory management, interrupts, scheduling, drivers, syscalls) is what people actually mean by the OS.
Using Limine for three architectures is a very reasonable call. Writing your own loader for x86_64 BIOS, UEFI, aarch64 and riscv64 is a big project of its own, and most of it is firmware plumbing rather than OS design.
If you want to be precise when you describe it, just say "kernel written from scratch, booted with Limine". That's honest and it's how most hobby OS projects put it.
One thing worth keeping in mind: since Limine already puts you in long mode (or the equivalent) with paging enabled and an HHDM, you skip the early-boot bits that a lot of tutorials spend time on. Later on it's still worth learning what Limine did for you (the GDT/paging setup it gives you, how it got the memory map from UEFI/BIOS), because you'll end up replacing its page tables and possibly its GDT with your own anyway.
2
u/nacnud_uk 3d ago
I would say it depends on how accurate you want to be. System is a big term. For me, as an FW person, the boot is, for sure, part of the system. You're not getting anything done without it, put it that way. Hardware is pretty dumb.
1
u/36165e5f286f 3d ago
I think it can be part of the system. It depends of the architecture you chose. If you like to have full control of the boot process (that could make the kernel do less work) and use a custom protocol and custom assumptions that yes I think it is part of the system. If you use a generic bootloader like limine or grub then no not really. The kernel will need to adapt to the boot protocol and handle everything itself !
2
u/Sostratus 3d ago
IMO everything that the system cannot run without is part of the system.
2
u/flatfinger 3d ago
Typically, the code in the boot loader will be used to bring some material into memory and then serve no function once that is complete. That does not imply that a system would need to work that way. It's also possible to have a boot loader set up an I/O mechanism which limits itself to using certain specific regions of memory, and for the rest of the system to leave those areas undisturbed while continuing to use that background I/O mechanism. The design of the PC BIOS would fit that pattern.
2
u/ventZl CMRX microkernel 3d ago
I'd say no.
2
u/LordRybec 1d ago
It really depends on how you plan on booting the OS. If you are going to use an existing bootloader, then no, the bootloader does not need to be part of the OS. If you don't want to use an existing bootloader, then yes it does need to be part of the OS (or you need to write your own bootloader separately).
I see people here saying that "nobody" counts the bootloader as part of the OS, but this is obviously false. MS Windows, one of the most popular operating systems of all time, has the bootloader built into the OS. DOS also had its bootloader built in as part of the OS. Pre-Unix Mac built the bootloader into the OS. Nearly all operating systems historically have had built in bootloaders. (Unix originally did not, as the bootloader was a separate, machine specific piece of code, entered by tape, punch card, or occasionally even by hand. Most modern Unix systems use built-in bootloaders, and they have for quite a long time.) The reality is, outside of Linux, most people view the bootloader as part of the OS, because for most of computing history the vast majority of operating systems included the bootloader as part of the OS.
Personally though, I'd treat them as two separate parts. Windows and DOS bootloaders don't boot anything except their own OSs. With UEFI BIOSes can handle booting using different bootloaders, but that's below the OS level. Generally if you need to care about the bootloader, you can treat it as a separate thing from the operating system, even though historically bootloaders were often just part of the OS. The advantage of using a bootloader that is not built into your operating system is that it's way easier to dual boot that way. Otherwise dual booting might require overwriting your OS bootloader with a universal bootloader that doesn't understand how to boot your OS. If the OS is designed to be booted from a universal bootloader, then many other bootloaders should support the method of booting it needs.
It's also worth noting that "built-in" can be pretty ambiguous. The bootloader is always a separate executable program from the rest of the OS. This is true even if it is designed for only a single OS and does not support any others. If you want to consider this as not part of the OS, there's not really any valid argument to counter that. But similarly, if you consider it to be "part of the OS" if the bootloader is custom for the specific OS, won't boot other operating systems, and is silently installed in the background with no option to not install it, that's just as valid. That's closer to the way I view it. If the developers of the OS obviously considered the bootloader to be an integral element of the OS, like Windows, DOS, old Mac, post 1980s Unix, and honestly nearly 100% of commercial operating systems, then I would consider it to be part of the OS. If the bootloader is an optional component, is designed to boot any OS, is developed by completely separate team that is not affiliated with the OS team, or is shipped or installed as a completely separate component that isn't directly affiliated with the OS, then I'd consider it to not be part of the OS. Yes, there is a lot of fuzzy ground between those two where it is not clear whether it should be considered part of the OS or not, and if you really need to classify bootloaders in that space, you can judge as you please.
If you are doing a tutorial for writing your own OS, and it treats the bootloader as not part of the OS, then I'd say treat it as not part of the OS. If you want to build a new bootloader that "is part of the OS" later, I hear it's easier that writing an OS, so you shouldn't have any trouble!
•
u/Grand-Satisfaction55 12h ago
No. The bootloader loads the OS. It's not part of the OS.