decisions DECIDED

152. The port-range capability: object and method semantics on the system call surface

calef, 2026-09-15, ratified the object, its one method, and the x86-only scope together. He ratified them when milestone 299 (the x86 port-range capability) landed the working driver behind them. This section records the one thing milestone 299 puts on the capability surface. The reason is that a new object type there is calef's to ratify (§10 (process model), §16 (object revocation)). The move fast on what can be undone tenet also files the system call surface under the irreversible category. The provisional names for the object, its method, and their fields are not ratified here. They stay on the worklist (script/names); calef takes those separately. DECISIONS §121 (what a device capability is) decided that x86 gets a port capability and why (the reversal at the end of that file). This decides what the object is and what invoking it does, the part §121 named but left for the milestone.

What it names

Object::PortRange(u16, u16) names a contiguous run of x86 I/O ports, (base, count). It is the device-capability kind for the one class of device with no page: x86's legacy port-I/O hardware, reached only by in/out. The MMU cannot grant or deny that hardware, because there is no page table in front of the port space. It is the honest analogue of Object::DeviceFrame, which names a device's MMIO page and is enforced by the MMU. PortRange names a device's ports and is enforced by the CPU's TSS I/O permission bitmap.

What invoking it does

Almost nothing, on purpose. Enforcement is at the context switch, not on the system call path, so a holder never invokes the capability to use the ports. It executes in/out directly. On switch-in, the kernel writes the holder's ports into the current core's TSS bitmap, so those in/out are permitted from ring 3 and no others (the lazy write; see §121's 2026-08-25 refinement and notes/benchmarks.md). A thread that holds no PortRange may touch no port at all.

The one method is PortRange::REVOKE (abi::port_range::REVOKE, method number 1), the take-back a live driver replacement needs. It has exactly DeviceFrame's asymmetric semantics, and for the same reason. It deletes every PortRange capability naming this range from every other thread and clears the cached grant. So those holders fault on their next in/out, while the caller keeps its own. It needs GRANT (you were trusted to lend the ports on, so you may take them back). The asymmetry is forced. The kernel mints a port capability once, at boot, so a symmetric revoke would strand the device forever. No other method exists; MAP has no meaning for an object with no page.

What it does not do

Names, ratified 2026-09-15

calef ratified the names in one pass, walking them by exposure. Two are renames the lane's first draft carried. This section records them as performed, so a reader meets the ratified name only:

name what it is note
PortRange the object variant twin of PageFrame/DeviceFrame
abi::port_range the ABI method module snake_case of PortRange, mirrors page_frame
port_range::REVOKE the one method matches page_frame::REVOKE's take-back
port_range_grant the per-thread field renamed from port_grant, for the shared port_range stem
set_port_range_grant the arch setter renamed from set_port_grant, same reason
revoke_port_range / _from_others the revoke.rs functions verb, matches the revoke family
X86_COM1_PORT_BASE / _COUNT COM1's ports (0x3F8, 8) arch prefix, standard COM1, PortRange's fields
port_write_byte / port_read_byte userspace byte port I/O spelled out; outb and inb are the x86 names and stay as doc(alias) (ruled 2026-11-20 UTC)
port_range_cap the capability constructor shares the stem
port_out / recv_then_port_out hand-assembled test fixtures describe what each tiny program does

The stem port_range was chosen to keep the family greppable as one string, the argument that renamed port_grant/set_port_grant. These are internal symbols nobody types, so brevity buys nothing. The shared stem buys a git grep port_range that finds the object, module, method, field, setter and constructor together.

BUGS