Skip to content

Elieren/Kernel-C

Repository files navigation

Kernel

Project Description

This project is an educational platform for step-by-step learning and development of basic operating system components. The goal is not to create a fully functional OS, but to understand how its key mechanisms work "from the inside."

preview

RoadMap

  • IDT initialization and interrupt handling (CPU exceptions + IRQs).

  • PIC remapping and sending EOI.

  • PIT (timer) — initialization and handler, incrementing uptime (seconds).

  • RTC — reading the current time (accounting for BCD/12h/24h formats, timezone offset).

  • VGA console: character output, scrolling, hardware cursor.

  • Keyboard handler: scan-code → ASCII, Shift/CapsLock, Backspace, Enter, string input with prompt.

  • System call vector (0x80) is already connected in the IDT — framework ready.

  • Add a syscall for string output to the terminal (sys_write).

  • Memory allocator.

  • Add power off and reboot to kernel.

  • Multitasking.

  • Create terminal.

  • Implement a basic file system.

  • Make the terminal a separate application rather than part of the kernel.

  • Implement Long mode

  • Implement working multitasking for Long mode (x86_64)

  • Rewrite terminal to (NASM x86_64).

  • Check syscall operation (status working)

  • Build kernel in iso with GRUB

  • Added support for BIOS and UEFI (Multiboot2).

  • Added commands ls, cd, pwd, mkdir, rm for working with the file system and moving around directories.

    • ls
    • cd
    • pwd
    • mkdir
    • rm
  • Added graphics mode with screen resolution support.

  • Added sleep support to power modes.

  • Added PCI driver for working with devices.

  • Added IDE driver for working with disks.

  • Support for Loading and Executing C User Programs in Kernel.

  • Added Spinlock for exclusive access.

  • Added Seqlock for frequent reading.

  • RSDP search and validation system added.

Iist of available commands:

To view the list of available commands, use the "help" command.

Build and Run

Build:

make 
  • All build artifacts (.o files and final binary) are placed in the build/ folder.

  • Final binary: build/kernel.

Run in QEMU:

  • Regular run (executes build/kernel):
make run 
  • Debug run with serial (stdout) output — useful for viewing kernel output and entering commands:
make debug 

Build with GRUB:

  • Make sure you have the necessary tools installed:
sudo apt install grub-pc-bin xorriso mtools 
  • Compile the project and generate the build/kernel and iso/boot/kernel files:
make 
  • Use grub-mkrescue to package the kernel into a bootable ISO image:
grub-mkrescue -o kernel.iso iso 
  • Run the generated ISO using QEMU:
qemu-system-x86_64 -cdrom kernel.iso -m 1024M 

Additional QEMU options:

  • You can pass options to QEMU via the QEMU_OPTS variable. Examples:
# Run with gdb stub and 512MB RAM make run QEMU_OPTS="-s -S -m 512" # debug + gdb make debug QEMU_OPTS="-s -S" 

Note: -s -S enables the gdb stub and halts the CPU until the debugger is attached.

Clean build:

make clean 

This will remove build/ and all build artifacts.