summaryrefslogtreecommitdiffstats
path: root/CONTEXT.md
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 02:18:30 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 02:18:30 +0200
commit76103215711d268b4b02f62e900f2be3032cf295 (patch)
treedcd86b5b02ae99c99ca833668055f4f53211be6b /CONTEXT.md
downloadrs-dos-76103215711d268b4b02f62e900f2be3032cf295.tar.gz
rs-dos-76103215711d268b4b02f62e900f2be3032cf295.zip
Initial commit: raisernics toy kernel
- Bare-metal x86_64 UEFI kernel (PE32+, no libc) - GOP framebuffer + 8x16 bitmap font - PS/2 keyboard (polling, scancode set 1) - UART 16550 serial driver (COM1, 115200 8N1) - Bump allocator as #[global_allocator] (alloc::String, Vec, format!) - UEFI memory map capture (static buffer, ADR 0001) - Shell with 7 commands (help, echo, clear, hello, info, mem, halt) - Dual output: GOP framebuffer + serial console - Makefile: run, run-gui, debug, release, image targets - tools/: qemu.sh, boot-image.sh, debug-kernel.py
Diffstat (limited to '')
-rw-r--r--CONTEXT.md100
1 files changed, 100 insertions, 0 deletions
diff --git a/CONTEXT.md b/CONTEXT.md
new file mode 100644
index 0000000..283467a
--- /dev/null
+++ b/CONTEXT.md
@@ -0,0 +1,100 @@
1# CONTEXT.md — raisernics Kernel Glossary
2
3## raisernics
4
5Custom x86_64 kernel for the RNG ecosystem. Toy project — self-contained,
6no strict userspace separation, TempleOS-inspired design philosophy.
7Built in Rust, compiled for the `x86_64-unknown-uefi` target (nightly).
8
9## Boot interface
10
11The kernel is a **PE32+ EFI application** loaded via UEFI `LoadImage`/`StartImage`.
12The existing bootloader (rsbl) loads us from `\bzImage` and passes the UEFI
13system table. No bootloader changes needed.
14
15## Output strategy
16
17Two-phase console model:
18
19- **Phase 1 (boot services alive):** UEFI `con_out->OutputString()` — works
20 with whatever UEFI firmware routes (serial + framebuffer).
21- **Phase 2 (native):** Raw serial UART 16550 driver on COM1 (I/O port
22 `0x3F8`). Activated after `ExitBootServices` when we own the hardware.
23
24## Dependency philosophy
25
26Aligns with RNG philosophy: minimal dependencies. Freestanding Rust,
27no libc, no external crates at the kernel/core level. UEFI protocol
28structs are hand-defined (not from `uefi-rs` crate) to stay lightweight.
29
30## Paging strategy
31
32Long mode mandates paging (`CR0.PG = 1`), so we accept that tax but keep it
33simple. Retain UEFI's identity-mapped 4-level page tables. No higher-half,
34no demand paging, no guard pages. When the kernel needs more physical pages,
35entries are added 1:1 to the existing page tables.
36
37## Physical memory
38
39Before `ExitBootServices`, the kernel reads the UEFI memory map to know
40which physical regions are free. Post-`ExitBootServices`, a simple physical
41page allocator (bitmap or free-stack) manages free pages. A bump allocator
42serves as the initial kernel heap.
43
44## Input strategy
45
46**PS/2 keyboard polling.** Port I/O to `0x60`/`0x64`. Scancode set 1
47(US QWERTY layout in the initial build). No interrupts — polling loop
48inside the shell.
49
50## Display strategy
51
52Two-phase model matching output:
53
54- **Phase 1:** UEFI `con_out->OutputString()` (framebuffer + serial handled
55 by firmware).
56- **Phase 2:** GOP (Graphics Output Protocol) framebuffer obtained before
57 `ExitBootServices`, driven by a built-in 8×16 bitmap font. Text rendered
58 by drawing glyphs directly into the framebuffer.
59
60The framebuffer address stays valid after `ExitBootServices` — the GPU's
61linear frame buffer is system memory that we own once boot services are gone.
62
63## Keyboard layout
64
65Scancode set 1, US QWERTY layout. Hardcoded scancode→ASCII table.
66Other layouts can be added later by swapping the translation table.
67
68## Development loop
69
70Standalone project — no integration with the RNG initramfs build system.
71Testing via QEMU with OVMF. The kernel PE binary is placed on a FAT
72image as `\bzImage` (matching rsbl's expected path).
73
74## Project layout
75
76Single Rust crate (`x86_64-unknown-uefi` target). Module breakdown:
77
78- `main.rs` — entry point, panic handler, top-level init
79- `uefi.rs` — UEFI protocol type definitions
80- `serial.rs` — UART 16550 driver
81- `paging.rs` — identity page table helpers
82- `memory.rs` — physical page allocator + heap
83- `gop.rs` — framebuffer access and text rendering
84- `font.rs` — 8×16 bitmap font data
85- `ps2.rs` — PS/2 keyboard driver (polling)
86- `shell.rs` — command loop and built-in commands
87
88## Milestone status (v0.1)
89
90✅ **Booting** — kernel loads via rsbl, prints banner via UEFI console
91✅ **ExitBootServices** — memory map captured via static `.bss` buffer
92 (see `docs/adr/0001-static-buffer-for-memory-map.md`)
93✅ **Serial** — UART 16550 at COM1, 115200 8N1
94✅ **Framebuffer** — GOP located, 8×16 bitmap font renders text
95✅ **Keyboard** — PS/2 polling, scancode set 1, US QWERTY
96✅ **Shell** — commands: `help`, `echo`, `clear`, `hello`, `info`, `mem`, `halt`
97
98## Target audience
99
100Learning exercise and toy. Not a Linux replacement. Not POSIX-compatible.