This project is a simple operating system that I built from scratch using Assembly and C, this work takes guidance and inspiration from:
Operating Systems: Three Easy Pieces.
The Little Book About OS Development.
The operating system uses GRUB as the bootloader, which is responsible for loading the kernel into memory during startup. From there, the kernel takes over execution and begins managing the system.
At its core, the kernel is simply a program in ELF format. GRUB loads this program into memory at specific addresses defined by the link.ld linker script.
- The kernel’s code is set to begin execution at address
0x00100000, as specified in the linker script. - Addresses below
0x00100000are reserved for low-level functionality, such as:- Memory-mapped I/O
- Frame buffer writing (both of which this OS utilizes).
The first of my own assembly code to get ran is in the loader.s file. The entry point is called loader and its purpose is to setup the stack and jump into the kernel C code entry point kmain.
nasmldgccgenisoimageqemu
Download the GRUB stage2 bootloader file:
wget -O stage2_eltorito https://github.com/littleosbook/littleosbook/raw/master/files/stage2_eltoritoIn order to build just the kernel.elf run:
makeIn order to build the full .iso run:
make isoTo clean build files:
make cleanIn order to run the iso in qemu run this command
qemu-system-i386 -cdrom os.isoThe following flag can be added to that command to allow debugging in the console, such as running info registers to view register contents.
-monitor stdio The following flag can be added to the command to view the output of the serial com port, this port is used for debugging information from the kernel.
-serial stdio The following command can be run to stop auto reboot and view a dump on a crash
qemu-system-i386 -cdrom os.iso -serial stdio -no-reboot -d int