The firmware is "something that doesn’t change or something that is not likely to change"; being firm! In the context of our modern computers, this is everything below the operating system (OS). There are many articles on making a BIOS; so, I will point out a few of the interesting points or new things from my end.
The boot process is fairly simple:
- CPU runs the firmware on the ROM chip of the motherboard.
- Firmware does a Power-On Self Test (POST) on all hardware components before activating them.
- A bootable drive is foudn and attempted to boot. This section always ends with
0xAA55.
- The bootloader loads into the address
0x7c00 in RAM, with control going over to this.
- The bootloader will hit the OS loader to boot in the kernel.
The author goes through an awesome setup for getting this going. Namely, they use nasm as an assembler and qemu for emulating the computer.
They go through the process of writing a bootloader that will print some text to the screen and nothing more. A few things are worth noting though: the file must be exactly 0x1FE in size, with the final two bytes being 0xAA55. The other interesting note is that the instruction [org 0x7c00] will tell the assembler (nasm) to load the program at the address 0x7c00.
What are interrupts? When the instruction int 0x# with # being an actual number is called, this will generate a temporary halt of the CPU to run special instructions. Within the Interrupt Vector Table (IVT), there is a list of function pointers that will be pointed to Interrupt Service Routines (ISR).
The ISRs are initialized by the firmware and are created by the manufacturer of the CPU itself, by default. This is special machine code that is executed whenever an interrupt is executed to do things, such as display characters on the screen and many other things.
Overall, good article on some things that have always felt like black magic before! I would recommend going through the complete process of writing the bootloader, to get an understanding of it.