Page 1 of 1

Usage of BIOS

Posted: Wed Jun 01, 2022 11:25 am
by sagiv
Hello there.
I'm fairly new to OS development, I try to absorb as much knowledge as I can from practical tutorials, NPTEL courses and the wiki.
I have stumbled upon https://wiki.osdev.org/Real_Mode_OS_Warning which is the warning of relying on the BIOS too much.
My question is, how else can I set up the environment in the first steps? because all the tutorials I have seen used BIOS interrupts to check for the A20 gate and get the memory map.
Thank you.

Re: Usage of BIOS

Posted: Wed Jun 01, 2022 9:23 pm
by Octocontrabass
sagiv wrote:tutorials
Be careful. OS development tutorials tend to have bugs in them.
sagiv wrote:My question is, how else can I set up the environment in the first steps?
Let the bootloader worry about that. You can write an OS without writing a bootloader.

If you end up writing your own bootloader, then your bootloader will use the BIOS (or UEFI boot services) to set up the initial environment, and the rest of your OS will not use the BIOS (or UEFI boot services).

Re: Usage of BIOS

Posted: Wed Jun 01, 2022 10:17 pm
by nullplan
sagiv wrote:My question is, how else can I set up the environment in the first steps? because all the tutorials I have seen used BIOS interrupts to check for the A20 gate and get the memory map.
That won't help you with any current PC, because those typically lack a BIOS (in favor of UEFI), and might not even support A20 mask functionality, because it has been a while since anyone used Turbo Pascal 3 on real hardware.

As Octo said, I would focus on writing a kernel and let it be loaded by a bootloader. If you want the challenge of writing a bootloader, you can do so later, and you can make your bootloader implement the same boot protocol used by your kernel. I actually use a double-wrapped approach, wherein the boot protocol for the actual kernel is bespoke, but I have a UEFI loader and a Multiboot 32-bit loader, and they just copy the information they receive from their respective environments into a unified structure for my kernel to use.

However, the days of the legacy BIOS are over, and no new project should be using it in this day and age.

Re: Usage of BIOS

Posted: Thu Jun 02, 2022 12:58 am
by sagiv
Octocontrabass wrote:
sagiv wrote:tutorials
Be careful. OS development tutorials tend to have bugs in them.
sagiv wrote:My question is, how else can I set up the environment in the first steps?
Let the bootloader worry about that. You can write an OS without writing a bootloader.

If you end up writing your own bootloader, then your bootloader will use the BIOS (or UEFI boot services) to set up the initial environment, and the rest of your OS will not use the BIOS (or UEFI boot services).
I will want to try my hand at a bootloader, eventually, but I guess for the time being I focus on the OS itself.
Thanks.
nullplan wrote:
sagiv wrote:My question is, how else can I set up the environment in the first steps? because all the tutorials I have seen used BIOS interrupts to check for the A20 gate and get the memory map.
That won't help you with any current PC, because those typically lack a BIOS (in favor of UEFI), and might not even support A20 mask functionality, because it has been a while since anyone used Turbo Pascal 3 on real hardware.

As Octo said, I would focus on writing a kernel and let it be loaded by a bootloader. If you want the challenge of writing a bootloader, you can do so later, and you can make your bootloader implement the same boot protocol used by your kernel. I actually use a double-wrapped approach, wherein the boot protocol for the actual kernel is bespoke, but I have a UEFI loader and a Multiboot 32-bit loader, and they just copy the information they receive from their respective environments into a unified structure for my kernel to use.

However, the days of the legacy BIOS are over, and no new project should be using it in this day and age.
Thank you, I will take it into consideration in my studies and research.