Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pastaboy12345/NKLegacy/llms.txt

Use this file to discover all available pages before exploring further.

NKLegacy is a Windows NT-inspired operating system kernel for x86 (i386), built entirely from scratch in C and x86 assembly. It boots either through its own two-stage NKBootman bootloader or via GRUB/Multiboot, sets up protected mode, initializes hardware, and drops you into an interactive NT-style command shell — all without any host OS dependencies.

Quickstart

Build and run NKLegacy in QEMU in under five minutes

Architecture

Understand the boot sequence, memory layout, and kernel design

Kernel Subsystems

GDT, IDT, interrupts, kprintf, and panic handling

Drivers

VGA text mode, serial debug, PIC/PIT timer, and PS/2 keyboard

Filesystem

NKFS in-memory RAM filesystem with directory tree and file I/O

Shell & PE Loader

Built-in command shell, NKBuild PE builder, and PE loader

What’s Inside

NKLegacy implements the full stack from the very first BIOS instruction to an interactive user shell:
1

Boot

The NKBootman MBR loads Stage 2, which switches the CPU to 32-bit protected mode and jumps to the kernel. Alternatively, boot via GRUB with the Multiboot protocol.
2

CPU Initialization

The kernel sets up the Global Descriptor Table (GDT) with kernel/user code and data segments, then loads the Interrupt Descriptor Table (IDT) with handlers for all 256 interrupt vectors.
3

Hardware Drivers

The 8259 PIC is remapped, the 8253 PIT is configured for 1000 Hz ticks, the VGA text-mode console is initialized, COM1 serial debug at 115200 baud is started, and the PS/2 keyboard driver is installed.
4

Shell

After mounting the NKFS in-memory RAM filesystem, the kernel launches an NT-style interactive shell with commands like DIR, CD, MKDIR, ECHO, TYPE, and the BUILD/RUN PE execution pipeline.

Key Features

  • NKBootman — Custom two-stage bootloader (MBR → Protected Mode), plus GRUB/Multiboot support
  • Protected Mode — Full GDT and IDT setup with ISR/IRQ handling
  • Hardware Drivers — VGA 80×25, COM1 serial, 8259 PIC, 8253 PIT at 1000 Hz, PS/2 keyboard
  • kprintf — Formatted kernel output to both VGA and serial simultaneously
  • NKFS — In-memory RAM filesystem (up to 512 KB, 256 nodes) with directory tree and file I/O
  • NT Shell — Interactive command shell supporting DIR, CD, MKDIR, ECHO, TYPE, CLS, VER
  • NKBuild & PE Loader — Minimal PE binary builder and in-kernel PE executor
  • Runtime Library — Freestanding string.h implementation (memset, memcpy, strlen, strcmp, etc.)
NKLegacy targets the i386 architecture and requires a cross-compilation toolchain with -m32 support. See Quickstart for the full prerequisites list.

Build docs developers (and LLMs) love