SchOS/docs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz 2d9a0ec6e3 ldls: being the PCI core, with offsets nobody wrote down
docs/plan/ldls.md milestone L2, less the half that needs /dev/pci.

In Linux, __pci_register_driver ends at the PCI core, which matches a
driver's id_table against the bus and calls probe(). There is no PCI core
here, so LDLS keeps the pointer that call was given and plays the part.

To do that it must know where pci_driver.probe is, and it asks the kernel
rather than being told by us. ldls/btf.c reads /sys/kernel/btf/vmlinux --
122,279 types, every struct layout and every function prototype, as generated
data describing the kernel that is installed. Implemented from
Documentation/bpf/btf.rst, which is a published specification.

    $ ldls-types /sys/kernel/btf/vmlinux --need
      pci_driver   probe      offset    16  size 8
      pci_dev      resource   offset  1000  size 1088
      resource     start      offset     0  size 8
      all present

Cross-checked against pahole on the same file, field for field. No offset in
this is ours, which is rule 3's uncomfortable row disappearing rather than
being argued about.

And then the driver:

      driver name "8139too"
      devices it claims: 10ec:8139 ... and 16 more
      calling probe(pci_dev 10ec:8139, ...)
        1  alloc_etherdev_mqs(0x368, 1, 1)
        2  pci_enable_device / 3 pci_request_regions / 4 pci_set_master
        5  pci_iomap(pdev, 1, 0)
        6..544  ioread8 / iowrite8 -- 0x88, 0x8a, 0x8c, 0x8e, over and over
      545  dev_addr_mod / 547 netif_napi_add_weight_locked
      549  timer_init_key / 550 register_netdev / 551 netdev_info
      probe returned 0 after 552 stub call(s)

10ec:8139 is the real RTL8139 id. It mapped BAR 1, the one marked
IORESOURCE_MEM. Those 538 alternating byte accesses stepping 0x88/0x8a/0x8c/
0x8e are serial EEPROM clocking -- the driver bit-banging the chip for its MAC
address and handing the result to dev_addr_mod. Then NAPI, a watchdog timer,
register_netdev, its "found it" line, and zero.

Fifteen distinct symbols carry that entire probe, and three of them are 540 of
the 552 calls. L1 said 44 symbols carry 110 modules through init; L2 says 15
carry this one through probe. Neither is a number anyone would have guessed
and both came from running the thing.

Recorded as not done, because it is not: probe receives a pci_dev whose shape
is right and whose contents are invented. The BARs are made up, pci_iomap
returns a zeroed page, and 8139too read a MAC address of zeroes and was
perfectly happy about it. The "all through /dev/pci" half of L2 belongs to the
SchOS side. Also recorded: BTF has to come from somewhere, and SchOS has no
/sys/kernel/btf/vmlinux -- the user brings it with the module, from the kernel
the module was built for.

make ldls-check is 27 checks, four of them L2's, and it says so out loud when
it skips them on a machine with no BTF rather than passing silently.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
2026-09-14 08:14:57 +02:00
..
architecture hybrid: a modeset, from a process 2026-09-14 01:36:05 +02:00
branding ldls: the plan for running someone else's drivers 2026-09-14 01:51:30 +02:00
guides docs: the tree moved and the documentation did not 2026-09-13 20:05:06 +02:00
history kernel: processes have an environment now, and zsh is the shell 2026-09-12 23:26:50 +02:00
plan ldls: being the PCI core, with offsets nobody wrote down 2026-09-14 08:14:57 +02:00
Website hybrid: H4 withdrawn -- USB is not a peripheral 2026-09-14 01:45:58 +02:00
licensing.md ldls: Apache-2.0, and where the boundary actually is 2026-09-14 07:52:01 +02:00
README.md freeze: one register for everything half-built, and the corners cleared 2026-09-13 20:28:05 +02:00

SchOS documentation

Four kinds of document, kept in four directories, because they answer four different questions and go stale at four different rates.

architecture/ What SchOS is Present tense. Describes what is built and working.
plan/ What SchOS will be Future tense. Everything here is unbuilt.
guides/ How to work on it Imperative. Build it, test it, add to it.
history/ Why it is the way it is Past tense. Bugs whose cause is not visible from the fix.

Plus two that belong to no category and apply to everything: licensing.md — read it before copying anyone else's code in — and branding/, which holds the marks and the rules for using them.


The rule that keeps this from rotting

When something is finished, it moves from plan/ to architecture/ and is rewritten as a description of the thing rather than a record of building it.

A completed item is not a ticked checkbox. A ticked checkbox says the work happened; it does not say what the work produced, and six months later the checkbox is the only thing left and it explains nothing.

So finishing a piece of work has three steps, and the third is not optional:

  1. The code works and is tested.
  2. The plan entry is deleted.
  3. A description exists in architecture/ written for somebody who was not there — what it does, what shape it has, what it costs, and what it still does not do.

This is not bookkeeping. The tree has already proved it necessary: the network stack was finished, verified end to end, and for a month afterwards the only description of it anywhere was a checkbox in a roadmap, four levels of indentation deep, written in the past tense of somebody arguing for the work rather than explaining the result.

The "what it does not do" section is the one that pays. Every description in architecture/ ends with one. A document that only lists a subsystem's strengths is marketing, and the reader who most needs the document is the one about to trip over a limitation nobody wrote down.


Start here

New to the tree → architecture/README.md, the system layer by layer, then guides/layout.md for where the files are.

Trying to build it → guides/building.md.

Wondering what happens next → plan/1.0.md, which is the finish line and the register of everything half-built. Then plan/README.md for the order.

About to start something new → the register, first. Nothing new starts while it has rows in it, and a row leaves only by being finished or deleted.

Something is broken and it feels familiar → history/. There is a good chance it is in there.


architecture/ — what SchOS is

README The system, layer by layer. Read first.
boot.md Firmware to the first userspace process.
kernel.md SchIFT: memory, processes, scheduling, traps, signals, SMP.
syscalls.md The call table, and the Linux personality that lets real software run.
filesystem.md The VFS, the buffer cache, procfs, mounts.
schfs.md SchFS: the copy-on-write root filesystem.
devices.md The device model, driver binding, the class vtables.
usb.md xHCI, the USB core, and the class drivers.
graphics.md Framebuffer, text rendering, console, and the crash screen.
terminals.md The six virtual terminals, and how one is switched to.
networking.md Drivers, lwIP, sockets — Unix and INET.
init.md schinit, PID 1 as a role, and the job manifests.

plan/ — what SchOS will be

README The three current decisions and the order they happen in.
1.0.md The finish line, and the freeze. What 1.0 contains, what is deferred, and the register of every half-built thing in the tree.
foundations.md The kernel work everything else is blocked on.
wayland.md The GUI stack, and what gets deleted to make room.
hybrid.md Moving drivers out of the kernel.
schapi.md The long-term API layering, and the compatibility promise.
roadmap.md Everything else still open.

guides/ — how to work on it

building.md Prerequisites and the build, per host.
testing.md The harnesses, and what each one actually proves.
layout.md Repository map, and how to add a program or a port.
adding-a-driver.md Writing one, binding it, publishing its class vtable.

branding/ — the marks

README Shift the logo, Guru the icon, SchCotie the mascot: what each is for, the colour rule, and why a raster is committed next to its SVG.

history/ — why it is the way it is

README What belongs in here and what does not.
kernel.md Bugs whose cause was nowhere near their symptom.
schfs.md The filesystem's own, from the same period as its design.
moving-to-linux.md The Windows-to-Fedora move, kept for the parts that recur.

Writing one of these

Four conventions, all of them observable in the existing files:

State the cost. Every design choice gave something up. A document that does not say what is a document that will be argued with later by somebody who only sees the downside.

Prefer the measured number to the remembered one. "500 of 3565 files carry the advertising clause" is worth more than "some do", and it was worth the minute it took to count.

Write down the bug that shaped it. Half the non-obvious code in this tree is non-obvious because something failed once. If a design is strange, the strangeness is load-bearing and the reader deserves to know why before changing it.

No dates in headings. A date in a heading turns a description into a changelog, and the description is the thing with a long life. Dates belong in history/, where they mean something.