CLOSE

In previous chapter we were into the single stage bootloader which have all its code in first sector (512 bytes) of the disk. However, we can't fit everything in the 512 bytes. Thus we need a way to read from the disk and load the file into the memory and jump to it.

For example, In second stage bootloader there are two stages:

  • Stage 1: Does just loading of the second stage and jumping to it.
  • Stage 2: Does a lot of stuff like enabling A20 line, loading the GDT, jumping to protected mode, loading the kernel and jumping to it. However these are just few things.

So, Here in Stage 1 we need a way to read Stage 2 file from the disk and load it to some known memory location and jump to that location, thus entering in Stage 2.

There are different ways to read from the disk:

  • Using BIOS (Interrupt 0x13 Function) (Legacy BIOS)
  • Direct Disk Access
    • his method involves directly interacting with the disk hardware, bypassing the BIOS. It provides more control and potentially better performance compared to using BIOS services. However, it can be more complex and less portable since it requires knowledge of the specific disk controller and hardware details.
  • Using UEFI Boot Services (Modern UEFI)