A minimal 32-bit x86 hobby operating system written from scratch in C and assembly. It boots with GRUB (Multiboot), prints to the VGA text screen, reads the PS/2 keyboard, and drops you into an interactive shell.
========================================
Welcome to MyOS
========================================
Type 'help' to list commands.
PgUp/PgDn scroll the screen, Up/Down recall commands.
MyOS> sysinfo
System summary
--------------
OS : MyOS 1.2.0 (32-bit x86)
CPU : QEMU Virtual CPU version 2.5+
Memory : 130559 KiB (127 MiB) usable
Bootloader : GRUB 2.12
PCI devices : 5
Virtualization : yes (TCGTCGTCGTCG)
- Multiboot-compliant boot (GRUB loads
kernel.elf) - Freestanding kernel with no libc
- VGA text-mode console (80x25) with colors, a working hardware cursor and 275 lines of scrollback
- PS/2 keyboard driver (scancode set 1): Shift, Caps Lock, arrow keys, Page Up/Down, Home/End
- Interactive shell with command history (Up/Down) and backspace editing across wrapped lines
- Hardware information: memory map from GRUB, CPU details via CPUID, PCI device list, RTC date and time
- Kernel panic handler (
kernel_panic) that shows an error screen and halts the CPU
Ready-to-boot ISO images and source archives are on the Releases page. Each release includes SHA-256 checksums.
qemu-system-i386 -cdrom myos-1.2.0.iso -m 128M| Command | Description |
|---|---|
help |
List available commands |
about |
About MyOS |
version |
Show the kernel version |
sysinfo |
System summary (OS, CPU, memory, bootloader, PCI devices) |
meminfo |
Memory size, kernel location and the full memory map |
cpuinfo |
CPU vendor, model, family/model/stepping, features, virtualization |
lspci |
List PCI devices (network, storage, graphics, ...) |
date |
Date and time from the RTC clock |
history |
Commands typed so far |
echo <text> |
Print text to the screen |
clear |
Clear the screen and scrollback |
reboot |
Restart the computer |
halt / shutdown |
Halt the CPU |
Keys: Up/Down recall previous commands, PgUp/PgDn scroll the screen, Home/End jump to the oldest/newest output.
myOS/
├── src/
│ ├── boot.S # Multiboot header, stack setup, entry point (_start)
│ ├── kernel.c # kernel_main: init console, start shell
│ ├── console.c # VGA console: colors, cursor, scrollback
│ ├── keyboard.c # PS/2 keyboard driver
│ ├── keys.h # Special key codes (arrows, Page Up/Down, ...)
│ ├── shell.c # Command-line shell
│ ├── multiboot.c # Boot information from GRUB (memory map, bootloader)
│ ├── cpu.c # CPU information (CPUID)
│ ├── pci.c # PCI device scanning
│ ├── rtc.c # Real-time clock (date and time)
│ └── panic.c # Kernel panic handler
├── iso/
│ └── boot/grub/grub.cfg # GRUB menu entry
├── linker.ld # Linker script (kernel loads at 1 MiB)
├── Makefile
└── LICENSE
- GCC with 32-bit support, and GNU Make
- GRUB tools (
grub2-mkrescue, orgrub-mkrescueon Debian/Ubuntu) andxorriso - QEMU (
qemu-system-i386) to run it; VirtualBox or VMware also work
Fedora
sudo dnf install gcc glibc-devel.i686 make qemu-system-x86 grub2-tools grub2-tools-extra xorrisoDebian / Ubuntu
sudo apt install build-essential gcc-multilib grub-pc-bin xorriso mtools qemu-system-x86make clean
make # builds kernel.elfCheck that GRUB recognizes the kernel as Multiboot (optional):
grub2-file --is-x86-multiboot kernel.elf && echo "Multiboot OK"If grub2-file is unavailable, use grub-file instead.
Build the bootable ISO:
make iso # copies kernel.elf into iso/ and runs grub(2)-mkrescueOr do it by hand:
cp kernel.elf iso/boot/kernel.elf
grub2-mkrescue -o myos.iso iso # or: grub-mkrescue -o myos.iso isomake run # builds the ISO and starts QEMU
# or, by hand:
qemu-system-i386 -cdrom myos.iso -m 128MA QEMU window opens with the MyOS welcome banner and shell prompt. Try:
sysinfo
meminfo
cpuinfo
lspci
To boot the kernel directly, without an ISO:
qemu-system-i386 -kernel kernel.elf -m 128MVirtualBox / VMware: create a 32-bit Other/Unknown VM with at least 64 MB of RAM and no hard disk, then attach myos.iso as the optical drive.
Real hardware: write the ISO to a USB drive or CD and boot in BIOS / legacy mode. Take care to select the correct device, as writing an image can erase existing data.
- GRUB reads
grub.cfg, loadskernel.elfat 1 MiB and jumps to_startusing the Multiboot protocol. boot.Ssets up a 16 KiB stack and callskernel_main.kernel_mainclears the screen and starts the shell.- The shell prints a prompt, reads keys through the keyboard driver (polling ports
0x64and0x60), and runs the command entered.
- Interrupts (IDT, PIC) and an IRQ-driven keyboard
- Physical page allocator (the memory map is already parsed)
- Kernel heap (
malloc) - Calling
kernel_panicfrom kernel error paths - Left/Right arrow editing inside the command line
- A simple filesystem
The roadmap below will move the kernel from a flat src/ folder to a modular layout. The files under arch/, drivers/, mm/, fs/ and proc/ do not exist yet. This is the target structure, not the current one.
myOS/
├── boot/
├── src/
│ ├── kernel.c
│ ├── console.c
│ ├── keyboard.c
│ ├── shell.c
│ ├── arch/i386/
│ │ ├── gdt.c # Global Descriptor Table
│ │ ├── idt.c # Interrupt Descriptor Table
│ │ └── interrupts.S # Interrupt/IRQ entry stubs
│ ├── drivers/
│ │ ├── timer.c # PIT timer
│ │ └── disk.c # Disk driver
│ ├── mm/
│ │ ├── physical.c # Physical page allocator
│ │ └── heap.c # Kernel heap
│ ├── fs/ # Filesystem
│ └── proc/ # Processes and scheduling
├── linker.ld
├── Makefile
└── iso/boot/grub/grub.cfg
Create the directories with:
mkdir -p src/arch/i386 src/drivers src/mm src/fs src/proc src/lib iso/boot/grubIssues and pull requests are welcome. For larger changes, please open an issue first to discuss what you would like to change.
Released under the MIT License.