A 64-bit operating system written from the metal up: SMP kernel, copy-on-write filesystem, Linux syscall ABI, Alpine packages, X11 on real hardware.
  • C 90.2%
  • Makefile 3.2%
  • PowerShell 2.3%
  • Shell 1.7%
  • Python 1.3%
  • Other 1.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz c84d06c5b1 gfx: one glyph blitter, and a terminal cell is a surface
Gate 0's last item, "delete the cell grid" -- done as far as it should be, and
the rest of it retired, which is the part worth explaining.

include/text.h made the case against the grid in four charges: it cannot do
variable-width glyphs, cannot position text off a multiple of eight, cannot
anti-alias, and cannot hold a codepoint above 255. Every one of those was
about the *drawing layer*, and every one is now false -- glyphs carry metrics,
PSOGM positions text at arbitrary pixels, the TrueType path blends 8-bit
coverage, and vtcell.ch is a uint32.

What is left is a grid in vt.c, and deleting that would not modernise the
console; it would stop it being a terminal. VT100 escapes address columns,
TIOCGWINSZ reports rows and columns, and every program that draws a box
assumes both. So the item is checked with its remainder rewritten to say what
was actually wrong, rather than ticked as if the original wording had been
carried out.

**What was actually wrong was the duplicate.** gfx.c walked font_data and
blitted glyphs its own way; text.c did the same job into a struct surface, for
no caller but a sysrq self-test. Two implementations of bearings, coverage and
clipping, which had to agree about a cell size only one of them was told had
changed -- and they did not agree, which is why every line of PSOGM once drew
the next character's bitmap underneath itself.

There is one now, and the mechanism is the pleasing part: the console hands
text_draw_glyph() **the cell as a surface of its own** -- same pixels, same
stride, origin moved and bounds set to that cell. Clipping a tall ascender to
its line is then the same bounds check that clips to the edge of a screen, and
there is no second notion of clipping in the tree. `surface_sub()` is six
lines and replaced fourteen of hand-written comparisons.

The bitmap is reached through font_builtin() like any other provider, so the
early console and the real one are one path with different metrics, and the
`if (!cfont)` branch that walked the array is gone. gfx.c no longer includes
font.h; text.c does, being the only file left that reads it -- which also
retires the note in text.c explaining why it could not.

struct surface gained a bpp, because gfx_draw_pixel handles 16, 24 and 32 and
whatever replaces it has to as well. Zero means 32: a UEFI GOP has no other
format and the loader publishes 32 unconditionally, so callers that do not
care say nothing.

One behaviour change, and it is the documented one: a codepoint the font
cannot draw is now a substituted glyph rather than a blank cell. text.h argues
for that directly -- "a missing glyph that draws nothing makes text silently
shorter and the fault impossible to see".

Verified by screendump: the console renders correctly, PSOGM renders
correctly, and `echo t > /proc/sysrq` still draws its specimen through the
surface path with the back buffer at 32bpp. Both supported configurations: one
boot each, no traps, no panics, socktest and memfdtest green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-23 17:57:16 +02:00
.claude/memory zsh: one word in a cross-compile cache, and every $(...) hung 2026-09-22 00:29:39 +02:00
boot gfx: the console's typeface is replaceable, and the loader is what replaces it 2026-09-23 17:47:45 +02:00
cmd gfx: the chosen resolution reaches every head, and the greeting stops racing 2026-09-22 22:19:00 +02:00
docs gfx: one glyph blitter, and a terminal cell is a surface 2026-09-23 17:57:16 +02:00
etc kbd: three layouts, and the arrow keys were sitting on top of UTF-8 2026-09-20 01:09:32 +02:00
include gfx: one glyph blitter, and a terminal cell is a surface 2026-09-23 17:57:16 +02:00
kernel gfx: one glyph blitter, and a terminal cell is a surface 2026-09-23 17:57:16 +02:00
ldls ldls: a second driver, and everything it found 2026-09-14 15:20:07 +02:00
lib unix: a bound socket is a file 2026-09-22 10:06:10 +02:00
ports zsh: two more cache answers that claimed capabilities SchOS lacks 2026-09-22 00:36:48 +02:00
projects freeze: one register for everything half-built, and the corners cleared 2026-09-13 20:28:05 +02:00
srv userland: 268 applets, an editor, names that resolve, and a web server 2026-09-14 19:24:55 +02:00
tools kmem: a slab allocator, and what the fixed tables actually cost 2026-09-22 09:32:06 +02:00
.gdbinit build: a gdb target, because the tree had no source-level debugger 2026-09-13 15:05:46 +02:00
.gitattributes Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
.gitignore kmem: a slab allocator, and what the fixed tables actually cost 2026-09-22 09:32:06 +02:00
LICENSE Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
LICENSE.MIT Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
Makefile vgpud: the second head shows the console, not a logo 2026-09-22 15:31:18 +02:00
NOTICE gfx: the second head shows the boot, not just what comes after it 2026-09-22 21:47:35 +02:00
README.md userland: 268 applets, an editor, names that resolve, and a web server 2026-09-14 19:24:55 +02:00
run.ps1 boot/uefi: the system information panel, and the offset that faked a version 2026-08-11 10:52:43 +02:00
shell.nix build: a nix shell, because the loader is the one thing gcc cannot build 2026-09-12 18:31:34 +02:00

SchOS

A 64-bit operating system, written from the metal up.

SMP · copy-on-write filesystem · TCP/IP · PCI, USB and virtio drivers · TrueType text · Linux syscall ABI


SchOS began as xv6 and is now mostly something else. The scheduler, the memory manager and the trap path have been rewritten for x86-64 and for more than one processor; the filesystem has been replaced outright; the syscall table speaks Linux numbering so that real software — musl, toybox, mksh — runs unmodified.

It is a hobby system built by one person, and it is honest about that: what works below has been run, not inferred, and the gaps are listed as plainly as the features.

The pieces

Layer Name What it is
System SchOS The distribution — kernel, userland, tooling
Kernel SchIFT Multi-core x86-64 kernel with a modular VFS
Filesystem SchFS Transactional, copy-on-write, the root filesystem
API SchAPI System programming interface — the stable surface
Compositor SchCom Display compositor (planned)
Window manager SchWM (planned)
Desktop SchDE (planned)

uname -s reports SchIFT, the way every Unix reports its kernel rather than its distribution.

What works

Kernel — Long mode, 4-level paging, preemptive multitasking. SMP: one, two and four processors all boot, with CPU enumeration from the ACPI MADT rather than the 1994 MP table. Memory sized from the E820 map, so it runs in tens of megabytes rather than demanding hundreds.

Filesystem — SchFS is the root: a copy-on-write B-tree with a uberblock ring, so a crash leaves either the old tree or the new one and there is nothing to repair. Free space is derived from the tree rather than stored beside it, which removes a whole class of disagreement. /proc/schfs shows the generation counter advancing as writes commit.

Processes — fork, exec, wait, pipes, signals, sessions and process groups, mmap (anonymous and file-backed), POSIX shared memory, Unix domain sockets, poll.

Devices — PCI enumeration with a bus-agnostic device model at /proc/devices. Drivers for e1000 networking, virtio-gpu and stdvga displays, xHCI USB with HID, hub and mass-storage class drivers, IDE, PS/2, serial. /dev/fb0 speaks the Linux fbdev interface.

Networking — ARP, IPv4, ICMP, UDP, TCP and DHCP, on lwIP behind a driver-agnostic interface class. Verified end to end from the host, both directions, rather than by inspection. Names resolve, so wget http://host/ works; httpd serves a directory back the other way.

Userland — musl, toybox, mksh and zsh, built from source. 268 applets: ls, cat, ps, top, wc, cp, mount, awk, bc, diff and the rest behave the way you expect, because they are the real programs. edit is kilo — arrow keys, Ctrl-S, Ctrl-Q, nothing to learn.

Text — a TrueType rasteriser (glyf outlines, composite glyphs, cmap format 4) replacing the 8×16 cell grid. JetBrains Mono for the terminal, Roboto for the desktop layer to come.

When it dies — PSOGM, the Purple Screen of Guru Meditation: stop code, fault address, call chain, and a QR code containing a text copy of the whole report.

Quick start

make          # kernel + UEFI loader + root filesystem
make qemu     # build it and boot it
make iso      # a bootable ISO for VMware or real hardware

Builds on Linux, macOS, FreeBSD/OpenBSD/NetBSD and Windows (Git Bash). The toolchain is clang + lld everywhere — it is a cross-compiler by construction, so one LLVM install targets the bare-metal kernel, the 16-bit boot code and musl userland from any host. See docs/guides/building.md for prerequisites per platform, and docs/history/moving-to-linux.md for moving a checkout between machines.

Testing

Booting to a prompt proves nothing: a filesystem can mount and still fail the first real command, and that has happened here. So the test harness drives the serial console and asserts on what comes back.

tools/windows/bootcheck.ps1            # boot, run real commands, check the answers
tools/windows/bootcheck.ps1 -Tty -Ps   # terminal behaviour, process enumeration
make schfs-check                       # SchFS B-tree, object and image suites

bootcheck is PowerShell because pwsh runs on every supported host.

Layout

kernel/     arch/ core/ dev/ drivers/ fs/ net/ proc/ sys/
  fs/schfs/     the filesystem -- same source the host tools compile
include/    kernel and userland headers
boot/       uefi/ (PE loader)  common/ (shared loader UI)
lib/ cmd/   first-party userland runtime and programs
ports/      third-party software built from source
tools/      windows/ (.ps1)  posix/ (.sh)  python/ (.py)  and .c/.pl
docs/       architecture/ (what it is)  plan/ (what's next)
            guides/ (how to work on it)  history/ (why it's like this)

docs/README.md is the index. If you are reading the tree for the first time, docs/architecture/README.md is the system layer by layer.

One rule worth knowing: the kernel and the host tools compile the same SchFS source. mkschfs cannot disagree with the kernel about the on-disk format, because there is only one implementation — found and fixed on the host, where a test takes a second instead of a boot.

Another: syscalls are declared in exactly one place, kernel/sys/table.inc. Everything else is generated from it.

Not there yet

  • No desktop. Schcom composites and routes input; the plan is now to put it on Wayland and delete the homegrown protocol. See docs/plan/wayland.md.
  • No descriptor passing. No sendmsg/recvmsg, so no SCM_RIGHTS — which is what the GUI work stops at. docs/plan/foundations.md.
  • No dynamic linking. exec handles static ET_EXEC only.
  • No page cache, so writable MAP_SHARED of a file is refused rather than faked.
  • A USB disk cannot be booted from — the root device is compiled in rather than selectable.
  • SchFS has no Linux driver yet; the plan is on-disk format version first, then FUSE, then a kernel module.
  • CFF/OpenType outlines and TrueType hinting are deliberately out of scope.

Licensing

Apache-2.0, copyright Nexoniarz. See LICENSE.

The kernel derives from xv6, which is MIT — see LICENSE.MIT. Third-party code redistributed in a built image (musl, toybox, mksh, zsh, kilo, the fonts) keeps its own licence; NOTICE carries the attributions. All of it is permissive — there is no GPL in an image this builds, which is why the userland is toybox and not BusyBox and the editor is kilo and not nano. See docs/licensing.md.

Drivers may be adapted from BSD sources, which are compatible. Linux drivers are not: GPL-2.0-only and Apache-2.0 cannot be combined and redistributed. Reading Linux to understand hardware is fine; translating a driver is not. Best of all is the public specification — xHCI, virtio, AHCI, e1000 — which carries no licence on what you write from it.


Built with stubbornness and a serial console.