lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

index.md (969B)


      1 +++
      2 title = 'Booting x86_64'
      3 +++
      4 # Booting x86\_64
      5 When you power on:
      6 1. CPU executes code from ROM
      7 2. Loads platform firmware (BIOS, UEFI, Coreboot..)
      8 3. Initializes memory and other devices
      9 4. Loads boot code into memory
     10 5. Executes boot code
     11 
     12 Memory layout before boot:
     13 
     14 ![Memory before boot](memory-before-boot.png)
     15 
     16 Two-stage bootloader:
     17 - BIOS only loads first disk sector, which is at least 512 bytes
     18 - first stage loads the second stage
     19 
     20 Memory map -- not all memory available yet
     21 - int 0x5; eax = 0xe820
     22 - bootloader sets this up, so `kmain(struct boot_info *)` already has the necessary info
     23 
     24 Loading the kernel
     25 - OpenLSD uses ELF format
     26 - kernel follows the bootloader
     27 - after setting up protected mode, boot loader reads kernel into memory and jumps to kernel entry function
     28 
     29 Mapping virtual to physical addresses
     30 - translation virtual → physical done by CPU (MMU) via page tables
     31 
     32 ![OpenLSD initial address space diagram](openlsd-initial-addr-space.png)