| Source / CMake target | Ownership |
|---|---|
src/common/ / scarletnx-common | AArch64 CPU state, instruction semantics, code discovery/emission, native module execution, runtime callback interface, host utilities |
src/nx/ / scarletnx-nx | Horizon SVC/kernel/services/filesystems, NSO/NRO loading, Switch memory, NVN and graphics/media backends, Switch frontend/tooling |
src/gnuabi/ / scarletnx-gnuabi | Linux syscall/errno/structure translation, ELF loading, isolated VFS, Linux process/memory/signal/futex compatibility |
The experimental src/3ds/ / scarletnx-3ds target supplies board profiles,
decrypted CIA/NCCH/ExeFS/RomFS extraction, or the same read in place from the mapped CIA, an independent checked page-memory
controller and a static-AOT pipeline for Linux and Windows hosts:
extraction -> the driver's offline compiler/host linker (only when the module is missing or stale) ->
a native module (an ELF shared object, or a DLL on Windows) -> checked process/ARM/Thumb dispatch. snx_ctr_process maps raw
ExHeader segments/BSS/stack/TLS; snx_ctr_native validates/loads module ABI 1.
The runtime uses no NX or GNU ABI code. common/filesystem/ / scarletnx-filesystem owns NX and CTR's shared
indexed host tree, immutable file mappings and on-demand opens. CTR uses its own
level-3 RomFS serializer/file objects and wire protocol, not Switch FS IPC.
Host staging/process utilities are also reused.
The shared A32 backend's A57/flat defaults are unchanged, and its CPU ABI is 3. ARM11 ISA and callback memory are explicit codegen options, never global 3DS defines. The shared backend CMake target is initialized once when several runtimes request it. The compiler exhaustively emits one-instruction entries for images up to 4 KiB. Larger images use bounded offline CFG discovery, code-pointer candidates and a bounded PC-relative ADD jump window, with blocks of at most 32 instructions. It emits 128 entries per chunk and links all PIC objects with a separate ABI-1 full-geometry index object; unproven targets remain NULL. There is no runtime discovery or compilation. SuperTux draws its title screen and plays its music through this path, without input yet. See 3DS port for coverage limits, absent HLE/devices and remaining cache/ISA work.
The common target has no runtime-specific imports. NX and GNU ABI each link
common and have no dependency on each other. The GNU ABI driver is the library
scarletnx-gnuabi (its file scarletnx-gnuabi-runtime), command line included, which
scarletnx runs as scarletnx-gnuabi. SNX_BUILD_NX=OFF builds GNU ABI without fetching or
linking NX graphics/media packages. CTest checks include ownership and the actual
transitive CMake dependency graph and target source ownership.
src/common/runtime/interface.h defines RtAPI; the active runtime supplies
the callbacks on CPU.rt. NX routes SVC to Horizon: its modules call each SVC's own entry through
RtAPI.svcs[imm], the number being a constant in the code. GNU ABI accepts SVC #0,
reads Linux syscall number x8 and arguments x0 through x5, and writes result
x0. CPU helpers and instruction emission are shared; Horizon handlers are never
used as Linux syscalls.
scarletnx is every driver the build has: src/multicall/main.c is the only main, and runs
the driver its name says from the library of the driver's own folder (snx_switch_program,
snx_ctr_program, snx_vita_program, scarletnx-gnuabi, snx_agb_program, snx_nds_program), so the recompiler
and SDL are in one program once. On Linux and macOS scarletnx-switch, scarletnx-3ds,
scarletnx-vita, scarletnx-gnuabi, scarletnx-agb and scarletnx-nds are symlinks to it. Windows has no
links: the driver's name goes first (scarletnx.exe scarletnx-3ds ...), and the launcher runs
the drivers that way (snx_menu_has_driver), as Android's does through libscarletnx-run.so.
A game's copy runs its driver too: a GBA or NDS game's by
its .ini (system=gba, system=nds), a 3DS or Vita game's by its title ID, any other the Switch's (or, in a
build without it, the one driver there is). The 3DS and Vita
drivers read what a module was compiled for from its file before loading it, and compile first
when it is stale, so a module is loaded once.
The original game-name entry points and CLI remain available. GNU ABI has an
independent CPU-only entry point; see GNU ABI for implemented
syscalls, ELF execution, filesystem scope, and differential testing.
Made from docs/dev/architecture.md at 69237645142c. GPL-3.0-or-later.