A minimal x86 operating system that displays CPU information using the CPUID instruction.
- Boots via GRUB using Multiboot specification
- VGA text mode display with color support
- Screen scrolling implementation
- CPUID instruction wrapper
- Displays CPU vendor, family, model, stepping
- Shows processor feature flags (SSE, AVX, etc.)
- Binary and hexadecimal number formatting
- Target: x86 (32-bit protected mode)
- Bootloader: GRUB (Multiboot 0.6.96)
- Display: VGA text mode at 0xB8000
- Memory: 1MB kernel load address, 16KB stack
- Here's the previous repo cpuinfo-os
- Fixed VGA buffer size (2000 vs 2200)
- Proper screen scrolling instead of clearing
- Corrected bit masking in CPUID parsing
- Fixed CPUID inline assembly with proper constraints
- Added CPUID availability check
- Displays CPU vendor string (leaf 0x00)
- Shows ECX feature flags (SSE3, AVX, AES, etc.)
- Added hexadecimal printing function
- Fixed binary printing for zero values
- Increased stack from 4KB to 16KB
- Added zig in the mix for additional or expermental things
- Added
-fno-omit-frame-pointerflag for better debugging - Added
.gdbinitfile for quicker and easier debugging with gdb
- GCC (with 32-bit support)
- GNU Binutils (as, ld)
- GRUB utilities (grub-mkrescue)
- QEMU (for testing)
- xorriso (dependency for grub-mkrescue)
- zig (for experimental things)
sudo apt install build-essential gcc-multilib grub-pc-bin xorriso qemu-system-x86 qemu-ui zigsudo pacman -S base-devel grub xorriso qemu-arch-extra qemu-ui-sdl zigmake # Build ISO
make run # Build and run in QEMU
make clean # Clean build artifacts
make debug # Run with GDB debugging# Assemble bootloader
as --32 src/bootloader/boot.s -o build/boot.o
# Compile kernel
gcc -m32 -c src/kernel/kernel.c -o build/kernel.o -ffreestanding -O2 -Wall -Wextra
# compiling zig objects
zig build-obj -target x86-freestanding -O ReleaseFast build/zigtest/hello.zig -femit-bin=build/hello.o
# Link
ld -m elf_i386 -T src/linker/linker.ld -o build/THBOS.bin build/boot.o build/kernel.o build/hello.o
# Create ISO
mkdir -p build/isodir/boot/grub
cp build/THBOS.bin build/isodir/boot/
cp src/bootloader/grub.cfg build/isodir/boot/grub/
grub-mkrescue -o THBOS.iso build/isodirqemu-system-x86_64 -cdrom THBOS.iso -m 512M -display sdl- Create new VM (Type: Other, Version: Other/Unknown)
- Disable EFI
- Mount THBOS.iso as CD
- Boot
Write ISO to USB:
sudo dd if=THBOS.iso of=/dev/sdX bs=4M status=progress.
├── Makefile # Build automation
├── README.md
└── src
├── bootloader
│ ├── boot.s # Assembly bootloader
│ └── grub.cfg # GRUB configuration
├── kernel
│ ├── kernel.c # Main kernel code
│ └── kernel.h # Type definitions and declarations
├── linker
│ └── linker.ld # Linker script
└── zigtest
└── hello.zig # zig files (in testing)0x00000000 - 0x000FFFFF: Real mode area (1MB)
0x00100000: Kernel load address
0xB8000: VGA text buffer- Resolution: 80×25 characters
- Format: 16-bit per character
- Bits 0-7: ASCII character
- Bits 8-11: Foreground color
- Bits 12-15: Background color
- CPU vendor string (GenuineIntel, AuthenticAMD, etc.)
- Maximum supported CPUID leaf
- EAX: Stepping, Model, Family IDs
- EBX: Brand index, Cache line size, APIC ID
- ECX: SSE3, SSSE3, SSE4.1/4.2, AES, AVX, etc.
- EDX: FPU, VME, TSC, MSR, PAE, MMX, SSE, SSE2, etc.
# Terminal 1
qemu-system-i386 -cdrom build/THBOS.iso -m 512M -s -S
# Terminal 2
gdb build/THBOS.bin
(gdb) target remote localhost:1234
(gdb) break kernel_entry
(gdb) continueTHBoS provides a set of custom GDB shortcut commands (auto-loaded from .gdbinit) to make kernel debugging faster and more intuitive.
These commands are designed for low-level OS development and work seamlessly with QEMU’s -s -S debug stub.
Start QEMU:
qemu-system-i386 -kernel build/THBOS.bin -m 512M -s -SStart GDB:
gdb build/THBOS.binThe custom .gdbinit in this project is auto-loaded and provides the commands documented below.
| Command | Description |
|---|---|
regs |
Displays all CPU registers. |
here |
Shows execution context: EIP, ESP, EBP, and nearby instructions. |
code |
Disassembles instructions around the current EIP. |
stack |
Dumps raw stack memory starting from $esp. |
frame |
Prints the EBP frame: locals, args, and return address. |
snap |
Full system snapshot (registers + stack + instructions). |
pg <addr> |
Dumps a full 4KB page from the given address. |
dump <addr> |
Hexdump of 128 bytes at the address. |
s1 |
Step 1 CPU instruction. |
s10 |
Step 10 CPU instructions. |
s100 |
Step 100 CPU instructions. |
runk |
Breaks at panic() and continues execution. |
- Add this:
set auto-load safe-path /into your~/.config/gdb/gdbinitfile - These shortcuts only work when GDB loads the project’s
.gdbinit. - The kernel must be run with
qemu-system-i386to avoid architecture mismatches.
qemu-system-x86_64 -cdrom THBOS.iso -monitor stdio- No interrupt handling (IDT)
- No keyboard input
- No disk I/O
- Uses GRUB's GDT (no custom GDT)
- No memory management
- Single-threaded
- No floating point support
- IDT setup with interrupt handlers
- Keyboard driver (IRQ1)
- Timer (PIT) for scheduling
- Custom GDT
- Memory management (paging)
- Shell interface
- Extended CPUID leaves (cache info, thermal, etc.)
- PCI device enumeration
