Cafe OS
Cafe OS is the operating system running on the PowerPC in Wii U mode. It consists of the Cafe OS kernel, the executable loader, and system libraries. Unlike on the Wii, where each game provided its own copy of Revolution OS with no isolation between libraries, Wii U applications run under the supervision of a common PowerPC kernel, isolating them from each other. All applications are modified ELFs, as are the libraries themselves, and applications dynamically link with them to gain access to OS services. Cafe OS also contains a few system processes, like the home menu and error handler. IPC to the IOP (IOSU) is managed by the Cafe OS Kernel and an IPC driver.
Pages
Kernel
The kernel runs in supervisor mode on the PowerPC, and performs the basic tasks of a microkernel. It is responsible for process isolation, memory management, and interrupt dispatching, as well as communication with IOSU. Cafe OS applications run as user mode processes, with separate address spaces and W^X memory protection.
Processes
A process in Cafe OS represents a single running application, with its own code, memory, and permissions. Cafe OS only executes the code of a single process at a time, but it can hold the data of multiple processes in memory simultaneously, and switch between them. Rather than allowing arbitrary process creation, there is RAM reserved for a single foreground app, a single background app, and various other special processes. Each running process is assigned a unique identifier called a RAMPID:
| RAMPID | Description | IOS Name |
|---|---|---|
| 0 | Cafe OS | COS-KERNEL |
| 1 | root.rpx | COS-ROOT |
| 2 | ??? | COS-02 |
| 3 | ??? | COS-03 |
| 4 | Background app | COS-OVERLAY |
| 5 | HOME Menu | COS-HBM |
| 6 | Error display | COS-ERROR |
| 7 | Foreground app | COS-MASTER |
In addition to RAMPID, Cafe OS processes have another type of process ID called a fixed process ID (PFID). Rather than representing which part of memory a process occupies, PFID actually specifies which specific app/task is running (browser, game, eShop, etc.). Cafe OS maps PFIDs to the RAMPID that they occupy when running (for example, a game is RAMPID 7 due to running in the foreground):
| PFID | Description | RAMPID |
|---|---|---|
| 0 | Cafe OS kernel | 0 |
| 1 | root.rpx | 1 |
| 2 | Wii U Menu | 7 |
| 3 | Nintendo TVii | ??? |
| 4 | E-Manual | ??? |
| 5 | HOME Menu | 5 |
| 6 | Error Display | 6 |
| 7 | Miiverse Post App | ??? |
| 8 | Internet Browser | 4 |
| 9 | Miiverse | ??? |
| 10 | Nintendo eShop | ??? |
| 11 | COS-FLV | ??? |
| 12 | Download Manager | ??? |
| 13 | COS-RSVD-13 | ??? |
| 14 | COS-RSVD-14 | ??? |
| 15 | Game | 7 |
| 16 | AOC Overlay App | ??? |
| 17 | amiibo Settings | ??? |
| 31 | Test Overlay | ??? |
Loader
The loader is responsible for loading RPL formatted libraries and executables into memory. It is a standard ELF executable named loader.elf. It includes a statically linked copy of zlib, probably for decompressing sections of RPL files.
Libraries
Cafe OS applications dynamically link with system libraries to get access to OS services. These OS services include memory management, graphics, audio, and controller input. All libraries are RPL files, a modification of the standard ELF format with compressed sections and more Windows-like dynamic linking. The main system libraries are listed below, with some having their own pages of documentation:
- avm.rpl - Audio/Video Manager
- camera.rpl - Gamepad camera
- coreinit.rpl - Kernel, memory, and FS
- dc.rpl - Display Controller
- dmae.rpl - DMA (Direct Memory Access)
- drmapp.rpl - Digital Rights Management
- erreula.rpl - Error Viewer
- gx2.rpl - Graphics
- h264.rpl - Support for H.264
- lzma920.rpl - LZMA SDK 9.20, functions match official library
- mic.rpl - Gamepad microphone
- nfc.rpl - Low-level NFC library
- nio_prof.rpl - IO Profiler
- nlibcurl.rpl - libcurl 7.21.7, functions match official library, has extra options for curl_easy_setopt
- nlibnss.rpl - libnss
- nlibnss2.rpl
- nn_ac.rpl - Nintendo Network Auto Connection
- nn_acp.rpl - Nintendo Network Account/Access Protection
- nn_act.rpl - Nintendo Network Accounts
- nn_aoc.rpl - Nintendo Network Add-On Content
- nn_boss.rpl - Nintendo Network Background Online Services (SpotPass)
- nn_ccr.rpl - GamePad management
- nn_cmpt.rpl - Handles transition into vWii
- nn_dlp.rpl - 3DS Download Play hosting library
- nn_ec.rpl - Nintendo Network E-Commerce
- nn_fp.rpl - Nintendo Network Friend Presence
- nn_hai.rpl - Helper library for interfacing nn_cmpt.rpl with Wii VC titles.
- nn_hpad.rpl - USB GameCube Controller/Adapter communication
- nn_idbe.rpl - Icon Database Entries (Downloads and decrypts game icons from an online icon database)
- nn_ndm.rpl - Network Daemons
- nn_nets2.rpl - More network functions
- nn_nfp.rpl - Nintendo Network Nintendo Figurine Platform (amiibo)
- nn_nim.rpl - Title installation
- nn_olv.rpl - Olive/OLV - Miiverse
- nn_pdm.rpl - System Play related data (play times etc.)
- nn_save.rpl - Save file access
- nn_sl.rpl - Quick Start Selection
- nn_spm.rpl - Storage related functions (USB?)
- nn_temp.rpl - TEMP library (for temporary files)
- nn_uds.rpl - Library for hosting 3DS Local-WLAN networks
- nn_vctl.rpl
- nsysccr.rpl - DRH communication (input and RPC)
- nsyshid.rpl - Human Interface Device library
- nsyskbd.rpl - USB keyboard library
- nsysnet.rpl - BSD sockets, network configuration, and SSL
- nsysuhs.rpl - Low-level USB access
- nsysuvd.rpl
- ntag.rpl - NTAG high level NFC library
- padscore.rpl - Wii Remote and Balance Board
- proc_ui.rpl
- snd_core.rpl - Sound-1 Core
- snd_user.rpl - Sound-1 User
- sndcore2.rpl - Sound-2 Core
- snduser2.rpl - Sound-2 User
- swkbd.rpl - Onscreen keyboard
- sysapp.rpl - Application jump/transition handling
- tcl.rpl - Texture Core library
- tve.rpl - TV Engine
- uac.rpl - DRH communication (Gamepad microphone)
- uac_rpl.rpl
- usb_mic.rpl
- uvc.rpl - DRH communication (Gamepad camera)
- uvd.rpl - AMD's OpenVideo Decode library, with some different function names
- vpad.rpl - Gamepad input
- vpadbase.rpl - Gamepad base library
- zlib125.rpl - ZLIB 1.2.5, functions match official library
Virtual Memory Map
| Virtual address start | Virtual address size | Physical address start | Flags | Description |
|---|---|---|---|---|
| 0x1000000 | 0x800000 | 0x32000000 | 0x2CE08002 | Loader and system libraries |
| 0x1800000 | 0x20000 | 0 | 0x28101200 | This is the codegen/JIT memory area, only available under processes which have it enabled under cos.xml (the size comes from cos.xml too) |
| 0x2000000 (variable) | 0xE000000 (variable) | 0x72000000 or 0xB2000000 (variable) | 0x2CF09400 | App executable and libraries (start varies, but end is always 0x10000000) |
| 0x10000000 | 0x52000000 or 0x92000000 (variable) | 0x20000000 (variable) | 0x28305800 | Application/library data area (may be smaller) |
| 0xA0000000 | 0x40000000 | 0 | 0x2000 | Overlay of application memory (used by loader?) |
| 0xE0000000 | 0x4000000 | 0x14000000 | 0x28204004 | Some sort of hardware communication area |
| 0xE8000000 | 0x2000000 | 0xD0000000 | 0x78200004 | |
| 0xEFE00000 | 0x80000 | 0x1B900000 | 0x28109010 | Loader data area (only mapped when running loader) |
| 0xF4000000 | 0x2000000 | 0 | 0x28204004 | MEM1 |
| 0xF6000000 | 0x800000 | 0x1B000000 | 0x3CA08002 | Loader chunk buffer |
| 0xF8000000 | 0x3000000 | 0x18000000 | 0x2CA08002 | Read-only shared data (system fonts mostly) |
| 0xFB000000 | 0x800000 | 0x1C800000 | 0x28200002 | |
| 0xFC000000 | 0xC0000 | 0xC000000 | 0x70100022 | Processor Interface |
| 0xFC0C0000 | 0x120000 | 0xC0C0000 | 0x70100022 | |
| 0xFC1E0000 | 0x20000 | 0xC1E0000 | 0x78100024 | VI |
| 0xFC200000 | 0x80000 | 0xC200000 | 0x78100024 | GFXSP |
| 0xFC280000 | 0x20000 | 0xC280000 | 0x78100024 | DSP |
| 0xFC2A0000 | 0x20000 | 0xC2A0000 | 0x78100023 | Write Gather Pipe |
| 0xFC300000 | 0x20000 | 0xC300000 | 0x78100024 | |
| 0xFC320000 | 0xE0000 | 0xC320000 | 0x70100022 | Espresso eFuses |
| 0xFD000000 | 0x400000 | 0xD000000 | 0x70100022 | Latte Registers |
| 0xFE000000 | 0x800000 | 0x1C000000 | 0x20200002 | |
| 0xFF200000 | 0x80000 | 0x1B800000 | 0x20100040 | Kernel heap |
| 0xFF280000 | 0x80000 | 0x1B880000 | 0x20100040 | |
| 0xFFC00000 | 0x20000 | 0xFFC00000 | 0x8100004 | Codegen area used with OSCodegenCopy |
| 0xFFC40000 | 0x20000 | 0xFFC40000 | 0x8100004 | Codegen area used with OSCodegenCopy |
| 0xFFC80000 | 0x20000 | 0xFFC80000 | 0x810000C | Codegen area used with OSCodegenCopy |
| 0xFFCE0000 | 0x20000 | 0 | 0x50100004 | |
| 0xFFE00000 | 0x20000 | 0xFFE00000 | 0x20100040 | Kernel ancast image |
| 0xFFE40000 | 0x20000 | 0xFFE40000 | 0x20100040 | |
| 0xFFE80000 | 0x60000 | 0xFFE80000 | 0x20100040 | |
| 0xFFEE0000 | 0x20000 | 0xFFEE0000 | 0x20100040 | |
| 0xFFF00000 | 0x20000 | 0xFFF00000 | 0x20100040 | |
| 0xFFF60000 | 0x20000 | 0xFFE20000 | 0x20100080 | |
| 0xFFF80000 | 0x20000 | 0xFFE60000 | 0x2C100040 | |
| 0xFFFA0000 | 0x20000 | 0xFFE60000 | 0x20100080 | |
| 0xFFFC0000 | 0x20000 | 0x1BFE0000 | 0x24100002 | |
| 0xFFFE0000 | 0x20000 | 0x1BF80000 | 0x28100102 | Per-thread data (e.g. pointer to thread descriptor and thread queue) at 0xFFFFFFE0 - 0xFFFFFFFC. |