SchOS/docs/plan
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
..
1.0.md ldls: being the PCI core, with offsets nobody wrote down 2026-09-14 08:14:57 +02:00
debugger.md debugger: who owns this page, and who just wrote to it 2026-09-14 01:17:57 +02:00
foundations.md sockets: a descriptor can cross between processes 2026-09-13 19:49:37 +02:00
hybrid.md hybrid: H4 withdrawn -- USB is not a peripheral 2026-09-14 01:45:58 +02:00
ldls.md ldls: being the PCI core, with offsets nobody wrote down 2026-09-14 08:14:57 +02:00
README.md ldls: the plan for running someone else's drivers 2026-09-14 01:51:30 +02:00
roadmap.md docs: the tree moved and the documentation did not 2026-09-13 20:05:06 +02:00
schapi.md freeze: one register for everything half-built, and the corners cleared 2026-09-13 20:28:05 +02:00
wayland.md freeze: one register for everything half-built, and the corners cleared 2026-09-13 20:28:05 +02:00

What happens next

Everything in this directory is unbuilt. When a piece of it is finished it leaves — deleted from here, rewritten as a description in ../architecture/. See the rule.

Read 1.0.md first.

It draws a finish line and puts most of the work below on the far side of it. Anything not named there is not being worked on, and the documents in this directory describe more than 1.0 contains.

It also holds the register of unfinished work, which is the one place anything half-built is listed. No new capability starts until that register is empty, and a row leaves it only by being finished or by being deleted from the tree.


The three current decisions

Taken together, because they turn out to need the same foundation.

wayland.md The GUI stack becomes Wayland. SchWM and SchDE are deleted — actually gone from the tree, not marked; Schcom survives and changes its wire format.
hybrid.md Built. All four mechanisms exist, the GPU driver runs outside the kernel, it survives being killed, and the display mode can be changed from a process. H4 (USB) was withdrawn rather than left open — USB is the bus peripherals arrive on, not a peripheral.
init.md Built. PID 1 is now a role the kernel refills; the description moved to ../architecture/init.md.

And the one they all wait on:

foundations.md Descriptor passing, shared memory, sockets in the filesystem. The critical path. Item 1 is built — sendmsg/recvmsg with SCM_RIGHTS.

And the one that says which parts of the above are actually being worked on:

1.0.md The finish line. Four gates, and everything else explicitly deferred.

And the one the hybrid mechanisms were built for:

ldls.md The Linux Driver Layer for SchOS. Someone else's drivers, in a process, reached through /dev/pci — because no project can write a driver for every device that exists. Not started.

And one that is a tool rather than a capability:

debugger.md A debugger for this kernel — one that observes rather than halts, and answers in this kernel's own vocabulary. Built, except the network transport: symbols, a log that outlives the kernel, /dev/dbg, the whose ownership query and hardware watchpoints are all described in ../architecture/debugging.md.

Two longer-horizon documents sit behind these: schapi.md, the API layering and the compatibility promise, and roadmap.md, which holds everything still open that is not one of the three above.


The order

Set by 1.0.md, which is the authority. In short:

0. Fix what is already wrong — first

Not a document of its own; it is Gate 0 of 1.0.md, assembled from the What it does not do sections in ../architecture/.

Before any new capability, and the reason is the one that put netdev_selftest() before the TCP/IP stack: a compositor built on a kernel with an unexplained hang and a socket layer that reports success for things it did not do will fail in ways indistinguishable from its own bugs.

1. foundations.md — the critical path

Both the Wayland work and the hybrid work stop here. Descriptor passing and shared memory are the substrate for handing a buffer to a compositor and for handing a device to a driver process. Doing it once for both is the entire reason these are one plan rather than three.

2. init.md — before the desktop, not after — done

A compositor being brought up for the first time crashes constantly, and something that restarts it and says why is worth far more during that work than at the end of it. Built; see ../architecture/init.md.

3. hybrid.md — moved up, and the reason is worth recording

This document used to put the hybrid work after 1.0, deliberately last, on this argument:

designing a userspace driver interface with no driver consuming it produces an interface that is wrong in ways nobody can see

The argument was sound and the conclusion drawn from it was wrong. What forced the change was the driver situation: SchOS cannot write a driver for every device that exists, no project can, and the only route to the hardware support an established OS has is a compatibility layer with the foreign drivers kept outside the kernel. That layer is this plan's mechanisms. It is not optional and it is not late work.

The original argument still holds, and it is answered rather than ignored: SchOS's own drivers are the consumers. vgpud is a real driver, with real requirements, and building the interface against it is what keeps it a general mechanism rather than a hole shaped like something foreign. The compositor is still a demanding consumer — it is no longer the only one available.

Four mechanisms, all built. One eviction done, the second withdrawn with its reasons recorded, and the foreign driver host — ldls.md — is what they were for.

4. wayland.md — with the GPU driver either side of the seam

W1–W3 and a terminal. W4 and W5 are post-1.0. Item 1 of foundations.md — descriptor passing — was the thing it could not start without, and it now exists.


In one sentence

Fix what is broken, build the descriptor-passing and shared-memory substrate, make init survivable, move the drivers out through an interface SchOS's own drivers have to live with first — and put a terminal on the screen.


What this plan does not address

Stated here so it is not mistaken for covered:

  • No IOMMU, so the hybrid work isolates against bugs and not against a hostile driver.
  • No page cache, so foundations.md delivers a memfd and not a general answer to shared file mappings. The general answer is still owed.
  • No garbage collector for descriptors in flight, so an AF_UNIX socket passed over itself and never received leaks. Bounded at thirty-two sockets, and nothing on this plan does it.
  • No dynamic linking, so no Mesa, no accelerated clients, and no third party shipping a .so for anything.
  • A new compatibility surface between PID 1 and PID 2, created by a plan whose own schapi.md §3 spends a section warning about those.
  • The three open networking items — getsockname, routing, and interrupt-driven receive — are untouched by any of this and still open. They are in roadmap.md.