newosdeveloper2021 wrote:How do bootloaders detect devices, peripherals, etc. on boot?
Short answer: they don't. Firmware does, and loaders just ask the firmware what devices it had detected.
newosdeveloper2021 wrote:I know sometimes it's designed and/or hardcoded for only certain stuff(as in some laptops), but how would you go about finding text mode buffer,
Under BIOS with VGA cards, that's always 0xB8000. Under UEFI, text mode buffer isn't supported at all.
newosdeveloper2021 wrote:refresh/polling rate of monitor/display, etc..
Bootloaders do not need these. But if they want, they could ask the firmware (BIOS/UEFI) for such an information.
newosdeveloper2021 wrote:Also, how do the EDK II/gnu-efi libraries work? Like how do they detect and write to devices such as NIC, GPU, CPU..
UEFI is designed in a way that everything is communicating through "protocols" (which aren't protocols at all, just interfaces). So if you want to know how many video cards are in the system, you ask the firmware to return handles to GOP interfaces. Likewise, if you want to know how many disks there are, you ask the firmware to return handles to block IO protocol interfaces.
"Writing" to a device is calling a method within a particular interface instance.
newosdeveloper2021 wrote:How do CPUs and proprietary drivers detect cpu temperature, etc.?
Bootloaders do not need these. And kernels have their own driver for the specific sensor device.
newosdeveloper2021 wrote:The guides and tutorials skim this and tell you to figure it out
Our wiki (pages like
boot seq,
bootloader) is the best source (follow the links like rolling your own bootloader, etc.). For BIOS, see
RBIL. For UEFI, see the official
spec. For a tutorial, check out the source of an Open Source bootloader, like
Limine,
BOOTBOOT, or GRUB (however this latter is a "bit" bloated, easy to get lost in its source).
newosdeveloper2021 wrote:use a library and dont do anything too low-level
For a library, take a look at
GNU-EFI (gcc only) or
POSIX-EFI (works with gcc and Clang too). But don't get high hopes about not doing anything too low-level, because writing an OS is all about being as low level as possible.
Cheers,
bzt