# The disc drive and its encryption; USB, SD and Wi-Fi as late ## The disc drive - **The drive**: Panasonic/Matsushita, DVD only (no CD), an MN102 controller "backwards compatible with the one on the GameCube" with additional commands (Hardware/Disc Drive). Its firmware is not Nintendo-readable by us and not modelled as code; it is a device model speaking the DI command protocol. - **The interface**: Hollywood's DI at 0x0d806000 (Starlet) with the GameCube register set (DISR, DICVR, DICMDBUF0-2, DIMAR, DILENGTH, DICR, DIIMMBUF, DICFG; Hardware/Drive Interface), Hollywood IRQ 18 and legacy PI IRQ 2. In Wii mode **IOS owns it**; games call `/dev/di` (/dev/di). In GameCube mode the game drives it at the Flipper address. - **New commands** (the GameCube's are gamecube-python's): the Wii read commands with offsets in 4-byte units, partition opening (the drive and IOS together), DVD-video reads (DVDLowReadDVD 0xD0, DVDLowReadDVDConfig 0xD1), which HW_COMPAT's DVDVIDEO bit blocks (Hardware/Hollywood Registers); the full list is on /dev/di (pinned; its ioctl table to transcribe as data when DI is built). - **The disc layout** (Wii disc, DOC): - Physical: DVD frames with a scrambler seeded from the disc ID, and BCA marks that real drives check (the page's "NROM" notes; drive-side, not modelled: the board takes user data, as every disc image holds it). - Logical: a GameCube-style header (game ID, maker, disc number, version, streaming flags, the Wii magic 0x5D1C9EA3 at 0x18), the partition table at 0x40000, region data at 0x4E000, a magic at 0x4FFFC. - Partitions: each has a **ticket** (with the title key encrypted by the common key), a TMD, a certificate chain, an **H3** table, and data in 0x8000-byte clusters: a 0x400-byte hash block (H0, H1, H2) and 0x7C00 bytes of AES-128-CBC encrypted data (Wii disc; Wii security). The H3 table's hash is in the TMD, the TMD is signed. - **Who decrypts.** On the hardware, IOS: the drive returns ciphertext, the Starlet decrypts with the AES engine and checks hashes with the SHA-1 engine (Wii security; IOS: DIP "including partition management and hashtree checks"). So: - **HLE `/dev/di`** returns plaintext partition data to the game, as IOS does. It needs the title key, hence the common key, **if the image is encrypted**. - Whether an RVZ needs the key depends on what RVZ stores. The WIA/RVZ design is understood to store partition data decrypted with the hash blocks dropped and recomputed on export (HYPOTHESIS: not verified here, and its documents live in Dolphin's GPL tree, which this repository does not fetch): U12. - **LLE** needs the ciphertext: an ISO, or an RVZ re-encrypted on the fly (with the common key). - **Disc formats the board reads (decision D9).** *Recommend*: plain ISO first (the Redump form, matching the DAT's SHA-1); RVZ through a conversion run as a closed box (Dolphin's `dolphin-tool convert`, from emu-tools-gpl) into a local ISO, until Aubrey decides whether the family writes its own RVZ reader. The census (census.md) shows the local library is RVZ only, 2,730 discs. - **Timing**: seek and read times are the drive's (motor, laser, the MN102's buffer). Not documented on the pinned pages beyond the GameCube's (U11: gamecube-python's drive model, extended). In HLE, the read completes at a FITTED time after the request. ## USB, SD and Wi-Fi: late Each sits behind a standard host controller in Hollywood and behind an IOS resource manager. They are needed by few games and by much homebrew. Order of work (decision D8): 1. **SD** (SDHCI at 0x0d070000, IRQ 7; `/dev/sdio/slot0`): the Host Controller Simplified Specification is public and WiiBrew says the controller is "just a standard SD host controller" (Hardware/SD Host Controller). A host-directory or image-file backed SD card. First of the three, because homebrew test programs load from SD and write results there: it is **test infrastructure**. 2. **USB** (EHCI 0x0d040000, OHCI0 0x0d050000; IRQs 4, 5; `/dev/usb/oh0`, `/dev/usb/ehc`, `/dev/usb/hid`, `/dev/usb/ven`, `/dev/usb/msc`, `/dev/usb/kbd` by IOS version): the controllers are standard (EHCI 1.0, OHCI 1.0a). Devices behind them (keyboards, microphones, the USB LAN adapter, mass storage, the Rock Band and Guitar Hero dongles) are separate device models, each its own small project. OHCI1 is built first, for the Bluetooth dongle (bluetooth-wiimote.md). 3. **Wi-Fi** (BCM4318 on SDIO at 0x0d080000, IRQ 8; IOS's WL and WD modules; "information on this device is scarce", Hardware/802.11 Wireless). LLE of the BCM4318 is out of reach (its firmware is Broadcom's, loaded by IOS). In HLE, networking is the `/dev/net/*` contract mapped onto a host network or a deterministic stub that reports "no connection". The stub is the default: networked services are gone (WiiConnect24, the Shop), and any real network breaks determinism. The Nintendo DS link through WD is out of scope. Each of the three gets a socket on the board (the controller with a device list), so device models are added without touching the board.