Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 2.73 KB

File metadata and controls

75 lines (61 loc) · 2.73 KB

TwoKernel

A hobbyist monolithic kernel written in c++. Trying to be posix style.

Resources

Limine-c++-template: https://codeberg.org/Limine/limine-cxx-template/src/branch/trunk/limine.conf

Roadmap

Completed

01 — Boot & C++ runtime

  • Limine config + base revision check
  • C++ global constructor invocation
  • hcf halt routine
  • Linker script

02 — Output & logging

  • Framebuffer driver
  • Flanterm-backed TTY
  • klog printf-style kernel logger
  • Minimal libc (memset/memcpy/strlen, etc.)

03 — CPU descriptors & interrupts

  • GDT load
  • IDT + ISR stubs
  • Exception handlers
  • PIC remap + IRQ mask scaffolding

04 — Memory

  • PMM with free-list allocator
  • VMM: 4-level paging, kernel HHDM mapping, kernel section mapping with NX, EFER.NX, CR3 load
  • Reclaim bootloader_reclaimable memory after VMM init (stub exists, not wired into kmain)

05 — Scheduling

  • Thread/Task struct (registers, kernel stack, state)
  • Context switch in asm (save/restore GPRs, RFLAGS, RIP, RSP)
  • Ready queue + round-robin scheduler
  • Timer-driven preemption (PIC timer ISR → schedule())
  • sleep/wait queues, blocking primitives
  • Idle thread

06 — Userspace

  • User CS/DS/TSS in GDT, IST stacks
  • Per-process address space (clone kernel-half PML4 entries into new pagemap)
  • User page mapping flags (USER bit) in VMM
  • ELF64 loader (program headers → mmap into address space)
  • iretq-based ring 3 entry
  • Syscall entry: SYSCALL/SYSRET, MSR setup (STAR/LSTAR/SFMASK)
  • Initial syscall set (write, exit, getpid, mmap, brk)

    06 - Impl userspace memory

      - [ ] Kernel heap (`kmalloc`/`kfree`, slab or bump-then-free-list on top of PMM)
      - [ ] Set up proper vaddr class for user process 
      - [ ] Set up where user threads points to the user vaddr rather than kernel
    
  • unmap should also free intermediate page tables when empty + INVLPG / TLB shootdown
  • Replace PIC with APIC + LAPIC timer (or HPET) — needed for preemptive scheduling
  • ACPI table parsing (RSDP/MADT) — feeds APIC/SMP
  • PS/2 keyboard or serial input for interactive debugging

07 — IPC

  • Pipes or message ports
  • Shared memory regions (VMM API for shared mappings)
  • Signals or equivalent async notification
  • Synchronization primitives exposed to userspace (futex-like)

08 — Virtual File System

  • VFS node abstraction (vnode/inode, ops table)
  • Mountpoint + path resolution
  • In-memory tmpfs as first backend
  • File descriptor table per process
  • open/read/write/close/stat syscalls
  • A real disk FS (FAT32 or ext2) and a block driver (AHCI/virtio-blk) when ready