Skip to content

Latest commit

ย 

History

History
161 lines (123 loc) ยท 6.9 KB

File metadata and controls

161 lines (123 loc) ยท 6.9 KB

PyramidOS

Kernel Version: v0.8.1 (Hardened) Architecture: x86 (32-bit Protected Mode)
Boot Standard: Legacy BIOS (Custom Bootloader)

PyramidOS is a sovereign, monolithic kernel operating system written from scratch in C and Assembly. It features a custom multi-stage bootloader, a robust memory management system, and a command-line interface inspired by the responsiveness of classic systems.


๐Ÿš€ Current Status

The system boots into a Protected Mode Shell with memory management, hardware interrupts, and timekeeping capabilities.

Component Status Description
Bootloader (Stage 1/2) โœ… Stable MBR, A20 Enable, E820 Map, Kernel Header Parsing, PM Switch.
Kernel Entry โœ… Stable Stack setup, GDT, IDT (Exception Handling), ISR Stubs.
Memory (PMM/VMM) โœ… Stable Bitmap Allocator, Paging Enabled (Identity Mapped).
PIC Driver โœ… Stable 8259 PIC Remapped to vectors 32-47.
Keyboard Driver โœ… Stable Scancode Set 1 translation, Shift/Caps state, Circular Input Buffer.
System Timer (PIT) โœ… Stable 8253 PIT configured at 100Hz for system ticks and sleep.
Real-Time Clock (RTC) โœ… Stable CMOS register parsing for Wall Clock Time (Y/M/D H:M:S).
KShell โœ… Stable Interactive command interpreter with history and backspace support.
Terminal (VGA Text Mode) โœ… Stable Text Mode (80x25) with hardware cursor support.
CPU Idle / Power Management โœ… Stable Uses STI+HLT (cpu_idle()) to avoid busy-waiting when idle.
Kernel Heap โœ… Stable Doubly-linked list allocator with kmalloc/kfree and coalescing.
VMM โœ… Stable Paging enabled; Heap mapped to 0xD0000000.
Storage (ATA/PIO) ๐Ÿšง In Progress LBA28 PIO reads (Read-Only) + IDENTIFY-based presence detection, stricter status checks.
Block Layer (Registry) โœ… Stable Generic BlockDevice registry; ATA registered only when a real device is present (disk0, optional disk1).
DevFS (/dev) โœ… Stable Virtual device filesystem exposing /dev/disk0, /dev/disk1, /dev/null, /dev/zero.
Partition Discovery (MBR) โœ… Stable Parses MBR and registers disk0p1..disk0p4 block devices (read-only).
VFS (Foundation) โœ… Stable Static mount table + FD table; / is nullfs, /dev is devfs.
PyFS (Read-Only Bring-up) ๐Ÿšง In Progress Probes disk0p1 and mounts at /py if superblock is valid; exposes /py/superblock for verification.

๐Ÿ› ๏ธ Building and Running

Prerequisites

  • System: Linux, WSL2, or MacOS.
  • Toolchain: gcc, ld, make, nasm.
  • Emulator: qemu-system-i386.

Quick Start

  1. Clean and Build (Release default):

    make clean && make

    Generates build/pyramidos.img and build/kernel.map.

  2. Optional: Debug Build:

    make clean && make debug
  3. Optional: Strict Warnings (Werror):

    make clean && make STRICT=1
  4. Run:

    make run

๐Ÿ”’ Repository Notice

This repository is currently private / all-rights-reserved. See NOTICE.

๐Ÿงน Project Hygiene

  • Formatting baseline: .editorconfig
  • Contribution guidance: CONTRIBUTING.md
  • Ownership / review routing: .github/CODEOWNERS

๐Ÿ’ป Kernel Shell Commands

Once booted, the KShell accepts the following commands:

  • help : List available commands.
  • clear : Clear the screen and reset cursor.
  • mem : Display Physical Memory stats (Total/Free RAM).
  • time : Display current Date and Time (from RTC).
  • uptime : Show system running time (ticks/seconds).
  • sleep : Pause execution for 1 second (Busy-wait test).
  • reboot : Restart the system (via Keyboard Controller).
  • diskread: Read and hex-dump a disk sector by LBA (e.g., diskread 0, diskread 60).
  • blkinfo : List registered block devices (includes disk0p1 after MBR scan).
  • mounts : List VFS mounts (expects /dev + optional /py).
  • pyfs_sb : Read /py/superblock via VFS (PyFS probe verification).
  • diagnose: Run kernel diagnostics (PMM/Heap/ATA).
  • crash : Force a kernel crash (for testing the panic/exception path).

๐Ÿ“‚ Project Structure

/
โ”œโ”€โ”€ Makefile                  # Master build orchestration (release/debug/strict)
โ”œโ”€โ”€ NOTICE                    # Private / all-rights-reserved notice (no license granted)
โ”œโ”€โ”€ docs/                     # Strategic, Architectural, and Tactical roadmaps
โ”œโ”€โ”€ boot/
โ”‚   โ””โ”€โ”€ src/legacy/           # 16-bit Assembly Bootloader (MBR + Loader)
โ””โ”€โ”€ kernel/
    โ”œโ”€โ”€ arch/
    โ”‚   โ””โ”€โ”€ i386/             # Architecture-specific code (x86)
    โ”‚       โ”œโ”€โ”€ entry.asm     # Kernel entry (stack + handoff to C)
    โ”‚       โ”œโ”€โ”€ idt.c/h       # Interrupt Descriptor Table
    โ”‚       โ”œโ”€โ”€ idt_asm.asm   # ISR/IRQ stubs
    โ”‚       โ””โ”€โ”€ cpu.h         # Registers + CPU helpers (cli/sti/hlt/idle)
    โ”œโ”€โ”€ core/                 # Kernel Core Logic
    โ”‚   โ”œโ”€โ”€ main.c            # Entry point / init ordering
    โ”‚   โ”œโ”€โ”€ pmm.c/h           # Physical Memory Manager
    โ”‚   โ”œโ”€โ”€ vmm.c/h           # Virtual Memory Manager
    โ”‚   โ”œโ”€โ”€ heap.c/h          # Kernel Heap Allocator
    โ”‚   โ”œโ”€โ”€ debug.c/h         # Panic system
    โ”‚   โ”œโ”€โ”€ shell.c/h         # KShell logic
    โ”‚   โ””โ”€โ”€ selftest.c/h      # Diagnostics
    โ”œโ”€โ”€ drivers/              # Hardware drivers
    โ”‚   โ”œโ”€โ”€ pic.c/h           # 8259 PIC (remap + mask control)
    โ”‚   โ”œโ”€โ”€ keyboard.c/h      # PS/2 keyboard (buffered input)
    โ”‚   โ”œโ”€โ”€ timer.c/h         # PIT driver
    โ”‚   โ”œโ”€โ”€ rtc.c/h           # RTC/CMOS wall-clock time
    โ”‚   โ”œโ”€โ”€ ata.c/h           # ATA PIO (read-only)
    โ”‚   โ””โ”€โ”€ terminal.c/h      # VGA text-mode terminal
    โ””โ”€โ”€ lib/                  # Freestanding libc-like helpers
        โ””โ”€โ”€ string.c/h        # Memory/string ops + atoi

๐Ÿง  Architecture Overview

  1. Boot Sequence: BIOS -> MBR (Stage 1) -> Loader (Stage 2) -> Protected Mode -> Kernel (0x10000).
  2. Initialization:
    • PMM: Reads E820 map, initializes Bitmap at 0x20000.
    • IDT: Sets up 256 interrupt vectors (Exceptions + IRQs).
    • PIC: Remaps IRQs to avoid CPU conflicts.
    • VMM: Identity maps lower 4MB, enables Paging (CR0).
    • HAL: Initializes Timer (100Hz) and Keyboard.
  3. Runtime: The kernel yields control to shell_run(), which blocks on buffered keyboard input while the CPU idles via cpu_idle() (STI+HLT).

๐Ÿ”ฎ Roadmap Snapshot

  • Current: Storage consumption bring-up: DevFS + MBR partitions + PyFS read-only probe.
  • Next Up: PyFS real directory/file reads + VFS-backed shell commands (ls, cat, etc).

See docs/ for detailed Roadmap Layers.