Experimental devices
An experimental device is a device that nobody has specified yet, tried out on Terse32 without a change to the specification and without changing any machine that does not use it. Its driver declares its calls, their charges and the size of its state; the core checks and charges the calls and keeps the state without knowing what the device means. The rules are spec/experimental.md in the Tersenet sources (with DEVICES.md section 15 for the driver's side); in short:
- **Slots 240 to 255.** They are never given to a numbered device. The slot is only the handle by which one image's program calls the device: call
(slot << 8) | function. - **A name.** The device is identified by a name of 1 to 30 bytes of
a-z,0-9,-and., starting with a letter, by convention the author's own word first (example.dice). The image names it in a table at the end of its ROM, whichterse build --optional 240:0=example.dicewrites andterse infoshows; the driver announces the same name. Nothing registers names. - **Optional only.** An image that lists an experimental device as required is refused by every host, so no program can depend on an experiment. Where the device is not granted,
devicereturnsFFFF_FFFFhfor its slot, every call returnsFFFF_FFFFhat a charge of 4, and the program runs without it. - **Where it is granted.** By
terse-bus: to a single machine, and in a shell (terse-bus --shell) to the shell and every program it starts, with a driver for that name and version, named for the run (--driver example.dice=./dice) or installed withterse drivers add.terse run,terse-hostandtcorenever grant one. - **One driver, every machine.** In a shell one driver process serves every program that uses the device, each with its own state, and each calls it on the slot its own image gives it: one program may use slot 240 and another 241 at the same time. A saved session keeps each program's device state; restored where the driver is missing, those programs fail with "needs a device" and the others come back.
- **Charges by the table.** Every call's charge, answered or deferred, is the base charge plus the rule the driver declared, computed by the core. A table has 1 to 16 calls, buffers of at most 4,096 bytes and bounded charges.
- **State.** At most 16,384 bytes that only the driver understands, kept with the machine's state, so the state hash, snapshots and recordings work; a machine without the device has the state it would have had before experimental devices existed.
- **Determinism.** The driver reads no clock, random source, file, network or environment: its results are a function of its reset state, the calls and a restored section. A program that wants chance seeds it from
random, which the host records. - **Not conformance.** An experimental device is outside the conformance programs, and no profile includes one.
- **Marked in the shell.** Device 8's
experimentalcall tells a shell which experimental devices a machine's image lists and whether it was granted each; the bundled shell marks such a program in its bar, its launcher line and the question before it starts (Using the shell).
The example, example.dice, is native/driver-experimental: the driver in C, a program that uses it and a test of every rule. The implementation guide's page "Invent a device" walks through it.