- When booting from a "hard drive", BIOS loads the first stage bootloader, either grub or bootloader.asm, starting at
_start. - The bootloader - or Qemu with
-kernel- sets up segments, switches to 32-bit protected mode, loads the service (an elf-binaryyour_serviceconsisting 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. - The bootloader hands over control to the OS, by jumping to the
_startsymbol 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. - The OS initializes
.bss, calls global constructors, and then callsOS::startin the OS class. - The OS class sets up interrupts, initializes devices, plugins, drivers etc. etc.
- Finally the OS class (still
OS::start) callsService::start()(as for instance here) ormain()if you prefer that (such as here), either of which must be provided by your service. - 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.