# IOS: high-level or low-level, frankly ## What IOS is, as far as the board is concerned IOS is Nintendo's (BroadOn's) microkernel on the Starlet (IOS page, DOC): - Processes talk through a file API (open, close, read, write, seek, ioctl, ioctlv) on `/dev/...` resources; the NAND filesystem is the fallback handler for `/`. - Broadway reaches it through **one IPC mechanism**: a 0x40-byte request (command 1-7, return value, file descriptor, five arguments) whose address goes in HW_IPC_PPCMSG, with the X1/Y1/Y2/X2 handshake (Hardware/IPC). Requests from Broadway "appear to come from" the PPCBOOT process (PID 15) and inherit the running title's UID. - About 25 resource managers in later versions: ES, FS/FFS, DI, OH0/OH1/EHCI/USB/HID/ VEN/MSC, SDI, NET/SO/SSL/KD/NCD/WD/WL, STM, crypto (`/dev/aes`, `/dev/sha`, `/dev/hmac`), and more (IOS, its module list for IOS59). - **Versioned by slot**: each title names its IOS in its TMD; 1-3 to 1-255; each branch has a frozen API and is patched only for bugs; "shadow" and stub versions exist (IOS; IOS history). The census holds 47 slots (census.md). - IOS can **reboot** Broadway (and is rebooted itself when a title asks for another IOS). ## The two ways to put IOS in a specification ### LLE: run Nintendo's IOS on a modelled Starlet The board models the Starlet core and every AHB device at register level; IOS is the player's firmware, read from the player's NAND. - **What it gets right by construction:** every IOS behaviour, including bugs, version differences, timing on the Starlet side (to the accuracy of the Starlet model), the order of AHB traffic, NAND wear, the System Menu. - **What it needs** that the family does not have and will not ship: - the player's **NAND dump** and that console's **OTP** (the NAND is encrypted with a per-console key and signed with a per-console HMAC key, both in OTP: Hardware/NAND, Hardware/OTP) and **SEEPROM** (the filesystem generation counter, boot2 counters: Hardware/SEEPROM); a NAND without its own console's keys is unreadable; - **boot0** to start from power-on (a mask ROM in the chip; only a die dump would give it), or a functional boot0 that checks boot1 against OTP's hash and jumps; - a Starlet core (arm926ejs-python, starlet.md) and the unknowns U5-U8 settled. - **What it cannot prove without hardware:** the Starlet model itself. With no Wii and no hardware-run Starlet test programs whose results are recorded (none found), an LLE run is "Nintendo's IOS ran on our model", not "our model is the Starlet". - **Cost:** every IPC request costs hundreds to thousands of Starlet instructions (HYPOTHESIS: a microkernel's message path, a resource manager, a reply), plus IOS's idle time if it spins rather than halts (domains-and-speed.md). ### HLE: specify IOS's service contract at the IPC boundary The board models the IPC registers, Hollywood's interrupt lines and the memory the requests point at; **behind the IPC is a functional model of IOS's resource managers**, written from public documents (WiiBrew's `/dev/*` pages, libogc's and libogc2's open-source callers, test programs). - **What it gets right:** what a game asks for and what it is told, when the contract is documented. Most games use a small, stable subset: `/dev/di` (disc reads), `/dev/fs` (saves and settings), `/dev/es` (title and ticket queries, launching), `/dev/usb/oh1` (raw USB transfers to the Bluetooth dongle, HCI inside), `/dev/stm` (power, reset button), `/dev/sdio`, sometimes networking (HYPOTHESIS: from the SDK's libraries' names in the Wii architecture overview and the IOS module list; a census of which resources each game opens would settle it, measured on the Rust tier, M7). - **What it does not get right, and must say so:** - **Timing.** When IOS answers is IOS's software running on a 243 MHz ARM. An HLE reply time is FITTED at best. Games poll or wait on IRQ 30, so a wrong latency shifts every later event. Every reply time in the specification is tagged FITTED or HYPOTHESIS, per resource, never DOC. - **Versions.** Behaviour differs between IOS slots and versions (bugs fixed, stubs, new ioctls). An HLE is one version's contract; the specification names the version it models per resource (by the census's SHA-1 of that IOS's TMD) and refuses, loudly, a request it does not model. - **The things IOS does that a game can see indirectly:** MEM2's top window becoming unreachable, HW_AHBPROT's value (homebrew reads it), the IOS heap pointers IOS leaves in low MEM1 (Memory map: 0x80003130/4), the version numbers IOS reports, the IOS reload a title causes. Each is part of the HLE's contract and listed in it. - **Security checks.** ES verifies signatures with Nintendo's certificate chain. An HLE either checks with the player's supplied certificates or does not check; not checking is a **named difference** (a fakesigned title runs where a real Wii refuses it). - **What it needs:** no Nintendo code. Disc data needs the common key only if the image is encrypted (firmware-keys-nand.md). ### What the other projects do (OBSERVED, implementation choices only) Dolphin (GPL-2.0-or-later; a closed box, never read) is widely known to HLE IOS rather than emulate the Starlet; its documentation and changelogs are not fetched here, so this is general knowledge, not a cited finding. skyeye-starlet (marcan) ran IOS on a hacked ARM emulator for research, "never meant to be released" (its GitHub description). No permissive LLE Starlet implementation was found. ## Recommendation (decision D4) 1. **HLE by default, as a functional level the charter allows** (era 4: "instruction and functional levels dominate"). The HLE is part of the specification, held to the same rules: every behaviour tagged, every reply time FITTED or HYPOTHESIS, the IOS version it models named, unmodelled requests refused. 2. **The Wii half's hardware is still modelled at register level** where Broadway can reach it directly: homebrew with HW_AHBPROT opened (the IOS page and Hardware/Hollywood Registers: TMD access rights make IOS OR 0x80000DFE into HW_AHBPROT) drives the NAND interface, AES, SHA-1, EHCI/OHCI and SDHC from Broadway. Those devices are the same objects an LLE Starlet would drive, so the HLE IOS does **not** fake them: it calls them, as IOS would (an HLE `/dev/di` read uses the DI block; HLE `/dev/fs` uses the NAND model). 3. **LLE later, as a judge of the HLE**, exactly as gameboy-python's real boot judges its skip-boot: the same title run both ways, and every difference recorded as the HLE's FITTED timing or a bug. It needs the player's NAND and keys, so it never runs in CI; it is Aubrey's or a player's local run. 4. **Never claim the HLE is IOS.** The claims file says: "the board's IOS is a functional model of IOS version V's documented services; its timing is fitted". The charter question this raises (for Aubrey): is an HLE IOS a **concession** (an approximation that changes results, switched and named) or a **modelling level**? The proposal is: a modelling level in the specification, because no exact alternative can be tested without Nintendo's code; with the LLE path, when it exists, as the exact reference and HLE marked against it. Decision D4.