跳到正文
cccskills
免费在 GitHub 公开

snx-service

Implement or fix a high-level-emulated Switch service or device (IPC commands, nvdrv ioctls, shared memory) so it answers the way the console does, as the game's SDK code expects. Use when a log shows an unimplemented command, a game stalls waiting on a service, an svcBreak follows a service call, or when adding audio, input, video or system services.

中文简介正在准备中。当前显示原文说明。

实测评分 未实测

查看安装方法

包含的文件(1)

  • SKILL.md6.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Services

Where

  • Interfaces are declared, not hand-dispatched: each service file has a .swipc beside it (in src/nx/: hle/services/acc.c and hle/services/acc.swipc, hle/services/network/bsd.swipc, hle/filesystem/fs.swipc), in SwIPC's language. docs/IPC.md has the language, the layout the generator applies and the C side. tools/swipc/swipc.c generates <file>.swipc.h and <file>.swipc.inc into build/<preset>/src/nx/snx_hle-swipc/. The service's C file includes the .inc, which has each handler's exact prototype; other files include the .h.
  • A command's handler is static int nn_ns_IFoo_Command(SvcObj* self, inputs..., outputs...): scalars by value, structs as const T*, buffers as IpcBuf (address, size), objects SvcObj* in and SvcObj** out, handles u32 in and u32* out. Outputs start zeroed. It returns 0 or RC(module, description), and a failure answers no outputs.
  • I_new(data_size) makes an object of interface I with zeroed state in o->data; I_register(ctor) registers a constructor under the .swipc's is names (services.c, or the service's own init). @stub answers success and zeros without a handler; @unsorted keeps a command's raw arguments in declaration order, for the few the SDK lays out that way; @fallback(fn) picks what answers undeclared commands (stub_ok, which logs, by default). types.swipc comes first in every snx_swipc list of the runtime's files, and in a test's that uses its types.
  • src/nx/hle/kernel/ipc.c: HIPC/CMIF parsing, replies, sessions, domains, the registry. services_int.h declares what the service files share.
  • In services/: hid.c (input and its shared memory), vi.c (display, binder), nvdrv.c (nvhost devices), audren.c (audren_update), pl.c (shared fonts), misc.c (the small services). src/nx/hle/filesystem/fs.c, and src/nx/gpu/video/ (host1x channels, NVDEC, VIC).

Procedure

  1. Find the command. -v logs every call: grep "IAudioOut cmd" run1.log | sort | uniq -c (the object's name is the interface's, nn::audio::detail::IAudioOut, but bsd's and ldr's carry the service's, bsd:u and ldr:ro). An undeclared command is logged by the interface's fallback, the first three times: [undeclared] I cmd N -> ok from stub_ok (success with no outputs: for a command that gives an object or a handle the game ends up calling through null), [unknown] from ipc_unknown, [not implemented] from bsd's, nothing from quiet_ok. [undeclared] NAME cmd N -> ok also comes from sm's stand-in for a service the runtime doesn't have. A [bad request] I cmd N: pid .., A .., ... -> InvalidCmifRequest means the declaration doesn't match what the SDK sends (step 2): the game gets an error, and often aborts on it. [bad request] ... -> InvalidNumInObjects is the same for a domain request's objects, and ... takes objects, on a session that isn't a domain -> NotSupported a command declared with objects called on a plain session. Switchbrew's page for the service gives the command's name and layout; libnx's client struct shows the raw layout and buffer attributes.
  2. Declare it in the .swipc with the console's full signature, inputs and outputs the runtime ignores included, and the exact buffer attributes (they decide the A/B/X/C list). Never write offsets by hand: the generator sorts raw arguments by alignment, ascending, as the SDK does (check a mixed-alignment command against the SDK's InRawArgumentInfo<size, alignment, offset> templates: a few use declaration order, @unsorted). pid is one 8-byte slot (write SwIPC's (u64, pid) as pid), aruid a command's ClientAppletResourceUserId slot.
  3. Read the caller. The game's SDK wrapper (nn::audio::..., nn::hid::...) shows what it reads from the reply and what it does with it. tools/symbols.py and tools/disasm.py on the wrapper, or the sdk-scout agent. A field the SDK reads and the runtime never writes is a bug even when nothing crashes yet.
  4. Answer like the console in the handler. Same result codes, same output values, same handle and event behavior. Where the console times something (audio buffers, vsync), keep the timing: games sync against it.
  5. Mind the threads. Service calls come from game threads, which run in parallel on the host. State shared between calls takes a lock (PMutex, pm_lock), events go through kevent_signal. An object whose every command needs a lock gets a dispatcher of its own around I_dispatch (fs.c's file_disp, dir_disp and fs_disp, ldr.c's ro_dispatch), and is made with svcobj_new and that dispatcher, not I_new.
  6. Verify with the scene that uses it (snx-run), and grep the -v log to see the new answers. A test that includes a service's C file generates that service's dispatchers itself (snx_swipc in tests/CMakeLists.txt).

References and licensing

Switchbrew documents commands and structures. Ryujinx (MIT) is the best behavioral reference and can be ported from with its notice. yuzu and its forks (GPL-2.0-or-later or GPL-3.0) can be ported too, ScarletNX being GPL-3.0-or-later: keep their copyright lines and say where the code came from. GPL-2.0-only code can't be (Atmosphère is read, never ported).

Known traps

  • Reporting more than one npad style for a controller makes the SDK assert in GetVibrationDeviceHandles.
  • An IAudioOut that never releases buffers stalls CRI movies after a few frames. The released-buffer array must be cleared first, because the SDK reads every slot.
  • WaitSynchronization with zero handles is legal (a plain sleep).
  • nvhost syncpoint ids above 127 overflow NvRmStream's tables: allocate with syncpt_alloc().

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Audits uncommitted changes, branches, or PRs for bugs, edge cases, SOLID/DRY/SRP, architecture, security, performance, and CLAUDE.md violations — then automatically fixes ALL issues and re-audits in a loop until clean. Use when: audit, review, code review, review this PR, check code, look over this, inspect code, or any variation.

中文简介正在准备中。当前显示原文说明。

scarletnx/ScarletNX2242026年10月25日 更新

Record what ScarletNX work taught, where the next session will look for it. Use after a bug took more than one attempt to find, when the same mistake happened twice, when a debugging technique worked, or when the user corrects how work is done.

中文简介正在准备中。当前显示原文说明。

scarletnx/ScarletNX2242026年10月25日 更新

snx-build

免费

Build the ScarletNX runtime and recompile games correctly, avoiding the setups that build "successfully" into something that doesn't work. Covers the CPM.cmake dependencies, the Clang-only presets, the deploy into games/, when a game needs recompiling, and the warnings a plain build doesn't show. Use when building, rebuilding, recompiling a game, after pulling or bumping a dependency, or when a build result looks suspicious.

中文简介正在准备中。当前显示原文说明。

scarletnx/ScarletNX2242026年10月25日 更新

RFC #142's C rules: strict ISO C99, no redundant state, indices not pointer chains, one allocation per owner, atomics apart, no stored pointers, one global struct per file. Use when writing or reviewing C in src/.

中文简介正在准备中。当前显示原文说明。

scarletnx/ScarletNX2242026年10月25日 更新

snx-crash

免费

Take a ScarletNX crash report, svcBreak or hang from the log to the mechanism that causes it, using the symbolizer and disassembler on the game's code. Use when the game crashes (signal 11 or 7), calls svcBreak or fatal, hangs, or when a log shows "*** Crash". Also for corrupted data showing up in game structures.

中文简介正在准备中。当前显示原文说明。

scarletnx/ScarletNX2242026年10月25日 更新

Write and optimize ScarletNX's own compute shaders (astc.comp, vic.comp, future ones) for what the GPU actually executes: constant tables, bit twiddling, uniform branches, fewer fetches, workgroup and subgroup structure, exactness proofs, and the GLSL-as-C++ tests and lavapipe timing that check them. Use when writing, reviewing or speeding up a GLSL shader under src/nx/gpu/, or when deciding whether to split one.

中文简介正在准备中。当前显示原文说明。

scarletnx/ScarletNX2242026年10月25日 更新

查看 scarletnx 的全部技能

报告此技能的问题