4.8 KiB
NT-Lite -- an x86-64 kernel
“Not only is UNIX dead, it’s starting to smell really bad.” - Rob Pike
“UNIX has three operations: read, write, and lie through ioctl.”
what is it?
NT-Lite is a 64-bit operating system kernel written from scratch.
It boots into a shell, loads drivers, launches programs, survives application crashes, runs Doom, plays video, talks TCP/IP, and occasionally reminds you that it is still a hobby kernel.
The codebase is small enough to understand, but no longer small enough to pretend it is just a weekend project.
features
- UEFI bootloader
- real SMP
- physical and virtual memory managers
- kernel pool and user heap
- single address-space design with user/supervisor page permissions
- HAL split from the kernel
- preemptive priority scheduler
- processes and threads
- per-process handles with rights checks
- process exit state, reaping, and restartable init services
- events, semaphores, mutexes, queues, named queues, and alertable waits
- IRQL, DPCs, kernel APCs, and user APCs
- native user-mode exception dispatch
- Win32 vectored exception handlers
- minimal runtime-registered SEH substrate
- async file I/O with events, IOSBs, APC callbacks, and cancellation
- VFS with IRPs
- page cache with dirty writeback and invalidation
- AHCI driver, interrupt-driven
- IDE driver, PIO/DMA
- FAT32 filesystem driver with VFAT long names
- USB bus, xHCI, mass storage, and HID
- VMware SVGA display driver
- drive-number paths such as
0:/apps/shell.exe - PE import resolution and dynamic
.sysdriver loading - modular networking through lwIP
- RTL8139 and RTL816x network drivers
- native BSD-ish socket syscalls
- DNS resolver syscall
- length-tracked string-view syscall ABI
- request-struct based syscalls for larger calls
- native
NTLSTATUS_*status codes - INI-based configuration
- partial Win32 personality
- partial (microsoft-level) POSIX personality
- Doom
- video playback
- fully GDPR-compliant
- everything but the kitchen sink
paths
"apps/shell.exe" -> current working directory
"0:/apps/shell.exe" -> volume 0, native path; works everywhere
"2:/data/config.ini" -> volume 2, native path
"C:\apps\doom.exe" -> volume 0 through win32.dll; C: maps to 0:, D: maps to 1:, etc.
"/apps/video.exe" -> volume 0 through posix.dll
"/1/apps/video.exe" -> volume 1 through posix.dll
Volumes 0-7 are available. A volume only works if a filesystem is registered on it.
The Win32 personality translates drive letters to volume numbers. The POSIX personality maps volumes into a tree.
how to build
- open the VS x64 build tools as administrator
- change into this directory
- run
build.bat - use one of:
run.bat— IDErund.bat— IDE, debugruna.bat— AHCIrunad.bat— AHCI, debug
how it looks when built
efi/boot/
bootx64.efi
boot.ini
drivers/
drivers.ini
ahci.sys
ata.sys
fat32.sys
lwip.sys
pci.sys
ps2.sys
rtl816x.sys
rtl8139.sys
usb.sys
vmwaresvga.sys
system/
colonel.exe
hal.dll
init.exe
syscall.dll
win32.dll
posix.dll
apps/
shell_native.exe
shell_win32.exe
shell_posix.exe
async_apc.exe
async_cancel.exe
doom.exe
video.exe
httpget.exe
tcpserve.exe
udp.exe
resolve.exe
ping.exe
screenshots
faq
Q: Is it secure? A: Don't connect to the internet with it.
Q: Who is this for? A: Me.
Q: What's next? A: todo
Q: Does it run Doom?
A: doom.exe
Q: Does USB work? A: It did for everything I threw at it.
Q: If I write a program now, will it run in the future? A: WE DO, in fact, BREAK USERSPACE.
Q: Can you read and write files?
A: As far as I'm aware.
Q: Does it have async I/O?
A: The best you'll get.
Q: Does the networking actually work? A: It didn't crash yet.
Q: Does it really have SMP? A: Watch out. It bites.
Q: Is the Win32 layer real?
A: Depends how you frame it. Real apps won't run but specifically prepared ones will.
Q: Are processes isolated?
A: No. But IPC is free. Is this how a serious modern OS should isolate processes? No.
Are we a serious OS? No. Is it very convenient? Absolutely.
Q: How often does it crash?
A: It doesn't if you don't touch it.
Q: Can it recover from a crash?
A: Works on my machine.
Q: Is this finished?
A: It will be once I get a job.
Q: Will it corrupt my data?
A: It shouldn't.
Q: Why is the path syntax so weird?
A: It makes sense to me.
Q: Why both Win32 and POSIX? A: NT could do it, why can't I?
Q: Why are the logs so verbose?
A: Try debugging an interrupt path with vibes.
Q: What should I read first?
A: This document.
Q: How do I contribute?
A: maksw@maksw.pl
Q: Can I use this in production?
A: Don't.
