The x86 boot process

  1. When booting from a “hard drive”, BIOS loads the first stage bootloader, either grub or bootloader.asm, starting at _start.
  2. The bootloader - or Qemu with -kernel - sets up segments, switches to 32-bit protected mode, loads the service (an elf-binary your_service consisting of the OS classes, libraries and your service) from disk. For a multiboot compliant boot system (grub or qemu -kernel) the machine is now in the state specified by multiboot.
  3. The bootloader hands over control to the OS, by jumping to the _start symbol inside start.asm. From there it will call architecture specific initialization and eventually kernel_start.cpp. Note that this can be overridden to make custom kernels, such as the minimal x86_nano platform used for the chainloader.
  4. The OS initializes .bss, calls global constructors, and then calls OS::start in the OS class.
  5. The OS class sets up interrupts, initializes devices, plugins, drivers etc. etc.
  6. Finally the OS class (still OS::start) calls Service::start() (as for instance here) or main() if you prefer that (such as here), either of which must be provided by your service.
  7. Once your service is done initializing, e.g. having indirectly subscribed to certain events like incoming network packets by setting up a HTTP server, the OS resumes the OS::event_loop() which again drives your service.