Skip to content

Experimental microkernel OS written in C# (NativeAOT) with a minimal assembly + C bootstrap. Runs bare-metal with no runtime dependencies. Exploring modern managed languages for systems-level development.

Notifications You must be signed in to change notification settings

justinamiller/CSharpMicrokernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CSharpMicrokernel

CSharpMicrokernel is an experimental microkernel operating system written primarily in C# (NativeAOT), supported by a minimal assembly + C bootstrap layer ("BootShim"). It is designed to run on bare-metal x86_64 hardware with no runtime dependencies, showcasing how modern managed languages can drive systems-level development.


Vision

The project explores the fusion of managed language ergonomics with low-level OS engineering. By leveraging .NET NativeAOT, we achieve: - Zero runtime dependencies on the target --- no libc, no CoreCLR, no operating system. - Bare-metal execution: runs directly on hardware or emulators. - Microkernel architecture: only essential primitives in kernel space (scheduling, IPC, memory management), while services (console, FS, drivers) live in isolated modules.

This is not just a proof of concept --- it is a platform to experiment with modern language design in OS construction.


Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   BootShim    β”‚   Assembly + C
β”‚  (boot.s)     β”‚   CPU bring-up, GDT/IDT, paging, stack
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Kernel C    β”‚   kmain.c, VGA, IDT, Keyboard, PIT
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ManagedCore   β”‚   C# (NativeAOT)
β”‚  Entry.cs      β”‚   Scheduler, IPC, Shell, FS
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • BootShim: Responsible for entering 64-bit long mode, building page tables, and handing off to C.
  • C Layer: Initializes interrupts (IDT/PIC), timers, and hardware drivers. Bridges unmanaged world to managed world.
  • ManagedCore (C#): Provides the microkernel's heart --- scheduler, interprocess communication (IPC), shell, and higher-level services.

Current Features

  • βœ… Multiboot2-compliant boot via GRUB\
  • βœ… 64-bit long mode bring-up (assembly)\
  • βœ… VGA text console output (C + C#)\
  • βœ… IDT setup + PIC remap\
  • βœ… PS/2 keyboard driver (IRQ1) feeding into C# shell\
  • βœ… Interactive shell in C# with commands (help, cls, echo)

Roadmap

  • PIT timer + uptime counter\
  • Cooperative β†’ preemptive scheduler\
  • Virtual memory manager with per-process address spaces\
  • IPC (send/recv/reply) channels\
  • Virtual File System (VFS) with RAMFS backend\
  • Disk drivers + FAT32 filesystem\
  • Networking (e1000 NIC driver + TCP/IP stack)\
  • User-mode processes and isolation

Build Instructions

Prerequisites

  • Windows 10/11 with Visual Studio 2022

    • Workloads: Desktop Development with C++, .NET desktop development
  • WSL2 (Ubuntu 22.04) (recommended) with:

    sudo apt update
    sudo apt install build-essential clang lld nasm make grub-pc-bin xorriso qemu-system-x86 dotnet-sdk-8.0

Build

# In WSL or Linux
make all

Run

make run

This will launch QEMU and boot the kernel ISO.


πŸ“‚ Repository Structure

CSharpMicrokernel/
β”œβ”€ BootShim/          # Assembly + C bootstrap
β”‚  β”œβ”€ boot/           # Assembly files (boot.s, gdt64.s, longmode.s)
β”‚  β”œβ”€ kernel/         # C files (kmain.c, vga.c, idt.c, keyboard.c)
β”‚  β”œβ”€ fs/             # Future: filesystem support
β”‚  β”œβ”€ drivers/        # Future: hardware drivers
β”‚  β”œβ”€ grub/           # grub.cfg
β”‚  β”œβ”€ linker.ld       # Linker script
β”‚  └─ Makefile
β”‚
β”œβ”€ ManagedCore/       # C# NativeAOT kernel logic
β”‚  β”œβ”€ Kernel.csproj
β”‚  β”œβ”€ Entry.cs
β”‚  β”œβ”€ Vga.cs
β”‚  β”œβ”€ Keyboard.cs
β”‚  β”œβ”€ Shell.cs
β”‚  └─ rd.xml
β”‚
β”œβ”€ build/             # Generated build outputs
└─ README.md

About

Experimental microkernel OS written in C# (NativeAOT) with a minimal assembly + C bootstrap. Runs bare-metal with no runtime dependencies. Exploring modern managed languages for systems-level development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published