A revolutionary operating system written in Rust that boots on bare metal x86_64 hardware with AI integration capabilities.
- Bare Metal Boot: Boots directly on x86_64 hardware
- Memory Management: Full paging and heap allocation with per-process page tables
- Interrupt Handling: Hardware interrupts (keyboard, timer)
- VGA Text Mode: Color terminal output with 16-color palette
- Keyboard Input: Real-time PS/2 keyboard driver with full character support
- CPU Context Switching: Full register save/restore for true multitasking
- Task Scheduler: Preemptive round-robin task scheduling with 10ms time slices
- Ring 0/3 Protection: Full kernel/user mode separation with privilege level enforcement
- Memory Isolation: Per-process page tables with separate user/kernel address spaces
- Disk I/O: ATA/IDE disk driver with PIO mode, LBA28 addressing, and sector read/write
- Filesystem: SimpleFS - custom filesystem with inodes, directories, and persistent storage
- System Calls: INT 0x80 syscall interface with 32 syscalls (exit, yield, print, get_time, get_ticks, sleep, getpid, getppid, fork, wait, kill, exec, signal, sigmask, pipe, read, write, close, shmget, shmat, shmdt, shmctl, seminit, semopen, semwait, sempost, semgetvalue, semdestroy, msgget, msgsnd, msgrcv, msgctl)
- Process Management: Process control blocks, process table, lifecycle management, parent-child relationships
- Signal Handling: Unix-like signals (20 signal types), signal masks, custom handlers, signal delivery
- IPC Mechanisms: Unix-like pipes (4KB circular buffers), signals (20 types), shared memory (System V-style), semaphores (POSIX-style), message queues (System V-style)
- Interactive Shell: 44+ commands for system control
- Virtual File System: In-memory VFS with Unix-like commands (ls, cd, cat, mkdir, touch, rm, write, exec)
- HAL Script Language: Turing-complete language with 32 built-ins and module system (see HALSCRIPT.md)
- Persistent REPL: Variables and functions survive across commands
- AI Natural Language Programming: Convert English to code with
aicommand - Example Scripts: 6 pre-loaded programs in
/scriptsdirectory - Standard Libraries: Math and string utilities in
/libdirectory - Application Platform: Built-in apps in
/appswithappcommand to run them - Command-Line Arguments: Pass arguments to scripts via the
argsglobal variable - Unit Tests: Comprehensive test suite for language components
- Rust Powered: Memory-safe kernel with zero-cost abstractions
- Production-Ready Kernel: 16+ CPU exception handlers for stability
- True Multitasking: Assembly-level context switching with full CPU state save/restore
- PIT Driver: Programmable Interval Timer for 100 Hz task scheduling
- System Call Interface: INT 0x80 handler with register-based argument passing
- Extensible: Easy to add new commands and features
MyOS
├── Bootloader (bootloader crate)
├── Kernel Core
│ ├── GDT (Global Descriptor Table)
│ │ ├── Kernel Code/Data Segments (Ring 0)
│ │ ├── User Code/Data Segments (Ring 3)
│ │ └── TSS with Privilege Stack Table
│ ├── IDT (Interrupt Descriptor Table)
│ ├── Ring 0/3 Protection (Kernel/User Mode Separation)
│ ├── Memory Management (Paging + Heap)
│ │ ├── Global Frame Allocator
│ │ ├── Per-Process Page Tables
│ │ ├── Kernel Space Mapping (upper half)
│ │ ├── User Space Mapping (lower half)
│ │ └── CR3 Switching Support
│ ├── VGA Buffer Driver
│ ├── Keyboard Driver
│ ├── PIT Driver (Programmable Interval Timer)
│ ├── ATA/IDE Disk Driver
│ │ ├── PIO Mode Read/Write
│ │ ├── LBA28 Addressing (up to 128 GB)
│ │ ├── Drive Detection & Identification
│ │ └── Sector-Level I/O (512 bytes)
│ ├── Context Switching (CPU state save/restore)
│ └── System Calls (INT 0x80 interface - 32 syscalls, Ring 3 accessible)
├── Process Management
│ ├── Process Control Blocks (PCB)
│ ├── Process Table & Lifecycle
│ ├── Parent-Child Relationships
│ ├── Process States (Ready/Running/Waiting/Sleeping/Zombie)
│ ├── Priority Levels (Idle/Low/Normal/High/Realtime)
│ ├── File Descriptors & Working Directory
│ └── Signal Disposition (per-process)
├── Signal Handling
│ ├── 20 Unix-like Signals (SIGINT, SIGTERM, SIGKILL, etc.)
│ ├── Signal Masks & Blocking
│ ├── Custom Signal Handlers
│ ├── Pending Signal Queue
│ └── Signal Delivery Mechanism
├── Inter-Process Communication
│ ├── Unix-like Pipes (pipe, read, write, close syscalls)
│ ├── 4KB Circular Buffers
│ ├── Reference-Counted Pipe Handles
│ ├── Read/Write End Separation
│ ├── Non-blocking I/O Support
│ ├── Shared Memory (shmget, shmat, shmdt, shmctl syscalls)
│ ├── System V-style Shared Memory Segments
│ ├── Named and Anonymous Segments (IPC_PRIVATE)
│ ├── Automatic Cleanup on Detach
│ ├── Semaphores (seminit, semopen, semwait, sempost, semgetvalue, semdestroy)
│ ├── POSIX-style Counting Semaphores
│ ├── Named and Unnamed Semaphores
│ ├── Atomic Wait/Post Operations (P/V)
│ ├── Process Waiting Queue
│ ├── Message Queues (msgget, msgsnd, msgrcv, msgctl)
│ ├── System V-style Message Queues
│ ├── Typed Message Passing
│ ├── Message Type Filtering
│ └── Queue Size Limits (8KB max message, 16KB max queue)
├── Task Management
│ ├── Preemptive Scheduler (Round-Robin)
│ ├── Task Creation & Execution
│ ├── Manual Context Switch API
│ └── Syscall API (32 total syscalls)
├── Shell & Scripting
│ ├── Interactive Shell (42+ commands)
│ ├── HAL Script Language (full Turing-complete)
│ ├── Persistent REPL
│ └── AI Natural Language Processor
├── Storage
│ ├── ATA/IDE Disk Driver
│ ├── Sector Read/Write Operations
│ └── Disk Information Commands
├── File System
│ ├── Virtual File System (VFS)
│ │ ├── Directory Tree (/home, /scripts, /tmp)
│ │ └── Unix-like Commands
│ └── SimpleFS (Persistent Filesystem)
│ ├── Superblock & Metadata
│ ├── Inode Management (500 inodes)
│ ├── Data Block Allocation (1000 blocks)
│ ├── Directory Support
│ └── File Operations (create, read, write)
├── Security & Protection
│ ├── ✅ User/Kernel Mode Separation (Ring 0/3)
│ ├── ✅ Privilege Level Enforcement
│ ├── ✅ Syscall Gate for Safe Kernel Entry
│ ├── ✅ Per-Process Page Tables
│ └── ✅ Memory Isolation (User/Kernel Address Space Separation)
├── Planned Features
│ ├── Complete Task-Process Integration (CR3 switching in scheduler)
│ ├── AHCI Driver (advanced disk interface)
│ ├── FAT32/ext2 support (industry-standard filesystems)
│ └── Network Stack
- Rust (nightly toolchain)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default nightly- QEMU (for testing)
# Ubuntu/Debian
sudo apt install qemu-system-x86
# macOS
brew install qemu
# Windows (via Chocolatey)
choco install qemu- bootimage tool
cargo install bootimage# Build the OS
cargo build
# Build bootable image
cargo bootimage
# The bootable image will be at:
# target/x86_64-myos/debug/bootimage-myos.bin# Run in QEMU
cargo run
# Or manually:
qemu-system-x86_64 -drive format=raw,file=target/x86_64-myos/debug/bootimage-myos.binOnce the OS boots, try these commands:
# File system
> ls /
> cd /home
> cat welcome.txt
> mkdir /scripts
> write /scripts/hello.hal "print \"Hello, World!\""
> cat /scripts/hello.hal
# HAL Script programming
> run x = 42
> run print x * 2
> run fn fib(n) { if n < 2 { return n } return fib(n-1) + fib(n-2) }
> run print fib(10)
# File I/O from HAL Script
> run write_file("/tmp/test.txt", "Hello from HAL!")
> run content = read_file("/tmp/test.txt")
> run print content
> run files = list_dir("/scripts")
> run print files
# Maps (dictionaries)
> run user = {"name": "Alice", "age": 30, "city": "NYC"}
> run print user["name"]
> run print keys(user)
> run print map_size(user)
# AI natural language programming
> ai create a fibonacci function
> ai show prime numbers under 50
> ai count from 1 to 100
> ai calculate 10 factorial
# Execute scripts from VFS
> ls /scripts
> exec /scripts/fibonacci.hal
> exec /scripts/primes.hal
# Import and use library modules
> ls /lib
> exec /scripts/demo_app.hal
> run import "/lib/math.hal"
> run print factorial(6)
# Run applications with arguments
> app list
> app run calc 10 + 5
> app run greeter Alice
> app run primefind 50
> app run filemgr list /scripts
# Task management
> ps
> spawn worker1 5
> spawn worker2 10
> ps
> sched
> kill 0
# Disk I/O
> diskinfo
> diskread 0
> diskwrite 100 "Hello from MyOS!"
> diskread 100
# Filesystem
> fsformat
> fsinfo
# System commands
> help
> about
> sysinfo
> uptime
> colorsString/Type: len(), str(), num()
String Methods: split(), trim(), upper(), lower(), replace(), starts_with(), ends_with(), substring()
Math: abs(), min(), max(), pow(), sqrt()
Array: range(), push(), sum(), pop(), reverse(), join()
Map: keys(), values(), has_key(), map_size()
File I/O: read_file(), write_file(), file_exists(), list_dir()
System: uptime()
Control Flow: break, continue (for loops and while loops)
See HALSCRIPT.md for complete language reference with examples.
### On Real Hardware (USB Boot)
⚠️ **WARNING**: This will overwrite the USB drive!
```bash
# Write to USB drive (replace /dev/sdX with your USB device)
sudo dd if=target/x86_64-myos/debug/bootimage-myos.bin of=/dev/sdX bs=4M && sync
Then boot from the USB drive on your PC.
- Convert the image to VDI format:
qemu-img convert -f raw -O vdi \
target/x86_64-myos/debug/bootimage-myos.bin \
myos.vdi-
Create a new VM in VirtualBox:
- Type: Other
- Version: Other/Unknown (64-bit)
- Use existing virtual hard disk:
myos.vdi
-
Boot the VM
myos/
├── src/
│ ├── main.rs # Kernel entry point
│ ├── vga_buffer.rs # VGA text mode driver
│ ├── serial.rs # Serial port for debugging
│ ├── interrupts.rs # Interrupt handling
│ ├── gdt.rs # Global Descriptor Table
│ ├── keyboard.rs # Keyboard driver
│ └── memory.rs # Memory management
├── Cargo.toml # Rust dependencies
├── x86_64-myos.json # Custom target specification
└── rust-toolchain.toml # Rust toolchain config
# Run kernel tests
cargo testSerial output is available on COM1 (0x3F8) for debugging:
# Run with serial output
qemu-system-x86_64 \
-drive format=raw,file=target/x86_64-myos/debug/bootimage-myos.bin \
-serial stdio- Bootloader integration
- VGA text output with 16 colors
- Interrupt handling (IDT, GDT, PIC)
- Memory management (paging + heap)
- Keyboard input (PS/2 driver)
- Interactive shell with 30+ commands
- HAL Script programming language
- Virtual file system (VFS)
- Persistent REPL
- AI natural language programming
- Task scheduler
- Multitasking
- User/Kernel mode separation (Ring 0/3)
- Memory isolation (per-process page tables)
- ATA/IDE disk driver (PIO mode)
- SimpleFS (custom filesystem with inodes and persistent storage)
- AHCI driver (DMA mode)
- FAT32/ext2 support
- Command shell
- Text-based UI
- Command parser
- AI command processing
- Natural language interface
- Embedded ML models (TinyML)
- Networking (TCP/IP stack)
- WebAssembly runtime
- Browser-based demo version
MyOS is designed to be:
- Fast: Rust's zero-cost abstractions ensure C/C++ level performance
- Safe: Memory safety without garbage collection
- Small: Minimal kernel footprint (~100KB base)
This is an experimental OS project. Contributions welcome!
MIT License
- BIOS/UEFI loads bootloader
- Bootloader enters protected mode
- Bootloader loads kernel at 1MB
- Control transfers to
_start() - Kernel initializes GDT, IDT, memory
- Interrupts enabled
- Enter main loop
0x0000_0000 - 0x0010_0000 : Real mode (1MB)
0x0010_0000 - 0x0020_0000 : Kernel code
0x4444_4444_0000 : Heap start (100KB)
0xb8000 : VGA text buffer