Commit graph eden-nx2-old/src/core
Author SHA1 Message Date
Takoroka
9677090712 nx2 services: callbacks no longer outlive their sessions
Under cdb title 1 reported "Free Heap block modified after it was freed"
when it recreated its display session (~4 min in); a run without the
debugger crashed at 113 s. The vi2 vsync timer callback (HostTiming thread)
captured the session and signalled its events; the destructor unscheduled
the timer (which does not wait for a running callback) and closed the
events. The syncpt slot actions (GPU thread) had the same race with
CloseEvent, as did the frame-capture and dump callbacks.

vsync events now live in state shared with the callback and are emptied
under its lock before closing; syncpt actions check a shared "alive" flag
under a mutex the destructor takes; capture/dump callbacks hold no session
pointers.
2026-10-28 17:22:54 -04:00
Takoroka
e69090383e Performance diagnostics and small wins for title 1
- eden-cli: SDL called SDL_AppIterate back to back, keeping a host core at
  100% polling input; run the main callbacks at 240 Hz.
- EDEN_NX2_IDLE_SPIN_US: optional spin before an idle core blocks (measured:
  no gain on title 1, so off by default).
- EDEN_NX2_SVC_TRACE=<first>:<last>: trace SVCs (with thread ids) for a range
  of presents only.
- MME DMA reads flush GPU-written memory first (never triggered on title 1,
  kept for correctness); render-enable override histogram instead of the
  first-400 log.

Measured on title 1's title screen (RTX 4070 Laptop): GPU ~20% busy, the six
emulated cores ~0.9 host cores in total, Eden's GPU thread 45-70% busy and
largely waiting: on host fences for semaphore acquires (GPU accuracy High
delays every release to host completion), on ASTC upload Finish(), and in a
1 ms poll sleep. gpu_accuracy=Low: ~12.5 -> ~16 fps.
2026-10-28 16:44:24 -04:00
Takoroka
6d7acfb990 Fix the P6 scratch save in R2UR/MATCH/HFMA2.RELU; GPU memory dump tool
The colour cast on title 1 (magenta/cyan, then red/green, changing per
course) came from the sky/atmosphere volume shader (a pixel shader drawing
a 32^3 RGBA16F table slice by slice), which starts with an unguarded R2UR.
R2UR, MATCH and HFMA2.RELU use P6 as scratch and saved/restored it with the
uniform-guard mask, 1 << (6 - 7) for an unguarded instruction: undefined, in
practice bit 31, which shifted into the opcode bits and turned the save into
another instruction. They now always save and restore P6.

Debugging aids used to find it:
- EDEN_NX2_DUMP=<present>:<addr>:<size>,...: flush GPU memory ranges at a
  present (on the GPU thread) and save them next to the frame captures;
  nx2work/vol3d.py untiles Switch 2 3D textures from such dumps.
- GPU::RunOnGpuThread.
- Logs of Switch 2 3D images and descriptors.
2026-10-28 15:19:44 -04:00
Takoroka
9e3f5cea40 Switch 2: nx2:gpu 215 DestroySparseRegion; log 214 arguments
nn::gpu::sdk names 214 CreateSparseRegion and 215 DestroySparseRegion.
215 (range in words 3-6, job slot in word 8) drops the GPU mapping and
completes its job behind the GPU; it was auto-stubbed and never signalled.
2026-10-28 13:22:59 -04:00
Takoroka
ed97c9b9dc debugger: monitor handles lists each handle's type and service event name
gdbrsp.py gains raw and monitor commands.
2026-10-28 12:31:45 -04:00
Takoroka
508f3400bd Switch 2: signal nx2:vi2 31/32 events on every vblank
Title 1's main thread waits on the vi2 32 event until it has fired twice
before it submits GPU work; Eden's stub never signalled it and the title
hung before its first frame. Signal the 31 and 32 events at 60 Hz.
2026-10-28 12:31:44 -04:00
Takoroka
8e7edfaa98 Switch 2: back GPU-only regions outside the application pool
nx2:gpu 214 regions are memory the graphics server keeps itself, but Eden
took their pages from the application pool: title 4's six 300 MB regions
left it 1.8 GB less than the 9.55 GiB the kernel reports, all of which
its heap and VAMM plan to use. Add 8 GiB of DRAM to the 12 GB layout for
the non-secure system pool and back the regions from there; the device
memory tracker now covers 32 GiB of physical memory.
2026-10-28 12:03:11 -04:00
Takoroka
98871aae52 kernel: EDEN_NX2_MEM_TRACE logs heap, physical memory and memory info requests 2026-10-28 12:03:10 -04:00
Takoroka
08c5ffd642 core: emulate six CPU cores
Switch 2 applications are given cores 0..5 (title 4's npdm) and start a
job worker per core. With four emulated cores, 4 and 5 were folded onto
0 and 1, so two cores ran two workers each. Switch 1 titles keep using
cores 0..3; core 3 stays the shared system core.
2026-10-28 11:29:20 -04:00
Takoroka
fcd02f8778 nx2: unmap GPU memory in submission order
NormalUnmapGpuMemory4K and destroying GPU memory are jobs the console's
graphics server completes behind the work already submitted. Run the GMMU
unmaps on the GPU thread after the command lists queued before them
(GPU::RunInOrder) and signal the job's event only then, instead of unmapping
and signalling at once while Eden's GPU thread may still be behind.

Also EDEN_NX2_FRAMES_AHEAD (experimental): wait for the previous frame's
fence at present instead of this one's.
2026-10-28 07:47:45 -04:00
Takoroka
c81a146fd5 vfs: keep the open-file cache below the CRT limit
The real VFS kept up to 8192 host files open, which is also the most the
Windows C runtime allows (_setmaxstdio(8192)). A game read from a loose RomFS
folder fills that within minutes (title 4: ~7300 handles after 160 s); from
then on every other open failed with "too many files open" - its next scene
pack, its save file, the shader cache - and the game waited forever on the
load. Cap the cache 512 below _getmaxstdio() on Windows.
2026-10-28 05:55:09 -04:00
Takoroka
42989ad8a9 nx2: pace Switch 2 presents to a 60 Hz vblank
The console flips one frame per vblank and holds the rest in the swapchain,
which caps a game at 60 fps. vi2 229 reports every buffer slot free at once,
so nothing paced title 4: it presented at 90-160 fps and its frame-stepped
timing, audio included, ran ahead. Hold each present until the next vblank,
scaled by the speed limit, without banking time lost to slow frames.
2026-10-28 05:55:09 -04:00
Takoroka
910e56d372 nx2: unmap GPU memory the game frees
nx2:gpu 213 (NormalUnmapGpuMemory4K) and 102 (destroy GPU-accessible
memory) were no-ops, so Eden kept freed memory mapped for the GPU. Title 4
frees its customization-room memory right after saving and reuses it as
ordinary heap; pending GPU->CPU write-backs for the old buffers then landed on
the new objects, and two threads crashed on garbage pointers ~5 s later
(the post-customization freeze).

Unmap the range from every address space (the GMMU unmap drops cached
buffers/images and their pending downloads), keep the registry's mapping
list in step, re-map 211 requests even at the memory's own address, and
drop freed regions from the semaphore mirror table, which every 8 KiB
allocation used to fill for good after 32 entries.
2026-10-28 04:56:16 -04:00
Takoroka
d4dc5af3be nx2: frame-locked input replay and quieter logs
EDEN_NX2_KEY_RECORD records keyboard transitions as "f<frame>:code" against a
global count of guest presents; EDEN_NX2_KEY_SCRIPT replays them on the same
frames (or by seconds, as before), so a played session reproduces exactly.

Debug aids: the PC/LR/SP of the first unmapped reads, NSO load addresses,
EDEN_NX2_IPC_SUMMARY (request counts every 5 s), EDEN_NX2_FORCE_LOD0.
Unmapped-access logging is rate limited and the per-draw/semaphore spam is
demoted, so long sessions stay under the log size cap.
2026-10-28 04:56:14 -04:00
Takoroka
f6cf565bbb nx2: get title 4 past the difficulty confirm
- MME: implement MME_DMA_READ / MME_DMA_READ_FIFOED (Turing macros read query
  results into their load FIFO; the conditional-render macro at 0x142 needs it).
- vi2 present waits up to 4 s for the frame fence (was 250 ms) so shader
  compile stalls don't let the game lap its equal-value gate semaphores.
- Native QMD: fire the third release slot at word 52, which NVN2 patches for
  queue-to-queue syncs (compute queue releasing a gate the 3D queue waits on).
- Compute class SET_REPORT_SEMAPHORE (0x6c0-0x6c3) releases.
- Ampere lowering: AOFFI, any LOP3 truth table, STG RZ, LDG 0x981, IABS,
  I2FP rounding, IMAD negated addend, SHFL 0x989 (all 77 title-4 shaders lower).
- Debug: EDEN_NX2_SEM_WATCH=<addr> traces acquires, releases, method
  arguments and compute macro emits for one semaphore block;
  EDEN_NX2_KEY_SCRIPT scripted key presses; per-submit logs moved to TRACE.
2026-10-28 00:24:14 -04:00
Takoroka
732778b124 Switch 2: present unflipped; fix frame-capture orientation
The vertical flip at present was a misreading: EDEN_NX2_FRAME_CAPTURE wrote the
TGA origin bit backwards (invert_y means the data is bottom-up), so captures
were upside down while the screen was right. Present unflipped again.
2026-10-27 23:10:17 -04:00
Takoroka
b8a278125e Switch 2: title 4 menu text renders upright
- Present flips the image vertically: title 4 renders with a lower-left origin
  (negative viewport scale), so its frames are stored bottom-up.
- Lowering: TEX/TEXS FP16 results (bit 79, packed half pairs) - the glyph
  shaders unpack them with HADD2.F32; LDG.E with a register address;
  SHF.R.U32 low word with a zero high word.
- Debug aids: EDEN_NX2_TRACE_PS / EDEN_NX2_WINDOW_TRACE_SKIP for the window
  trace, EDEN_NX2_TEXTURE_DUMP, EDEN_NX2_TRACE_DST for copies; RT trace keyed
  by shader pair. NX2_NOTES: blockers 53-57, next steps.
2026-10-27 23:04:22 -04:00
Takoroka
d754fff776 Switch 2: back GPU-only regions, pace presents, interleaved split methods
- gpu 214 creates GPU-only memory the graphics server backs itself (title 4
  renders everything into six 300 MB regions at 0x81_0000_0000). Back each
  with application-pool pages mapped into the alias code region and map that
  for the GPU. This is what made title 4's frames appear.
- vi2 229 waits (bounded) for the presented frame's GPU fence: the reply
  reports every buffer free, so without this the game laps Eden's GPU thread
  and rewrites command memory it has not read yet.
- Split methods: keep several parked methods keyed by resume address (NVN
  interleaves command buffers) and drop them when the submission ends.
- hid 214 (per-frame vibration send) answered quietly.
- Debug aids: EDEN_NX2_WINDOW_TRACE / EDEN_NX2_RT_TRACE (render targets,
  clears, textures), EDEN_NX2_AUDIO_LEVEL (output peak), EDEN_NX2_PB_DUMP
  (command list for offline replay), parsed-entry change check.
2026-10-27 22:28:10 -04:00
Takoroka
09630c34ed Switch 2: suspend channels on semaphore acquires; fix pushbuffer desyncs
NVN2 gates command buffers with semaphores the CPU releases after writing
them. Eden read past unmet SEMAPHORED acquires, so it executed stale commands
and desynchronised. Channels now suspend on an unmet acquire and resume from
the same word once it is met (scheduler keeps the waiting channels, the GPU
thread polls them), as in changes.patch.

Also: methods split across GPFIFO entries around a called command buffer are
set aside and resumed; subchannel 2 defaults to inline-to-memory; unbound
subchannels and out-of-range compute/DMA methods are dropped instead of
crashing; 4-byte semaphore releases no longer write 16 bytes; Ampere
SEM_PAYLOAD_HI/SEM_EXECUTE no longer spin as Kepler acquires; unmapped GPU
reads log instead of asserting. Debug aids: EDEN_NX2_PB_CHECK (pushbuffer
changed after submit), EDEN_NX2_QUERY_TRACE, a one-time pushbuffer dump.
2026-10-27 20:53:15 -04:00
Takoroka
c43191ee4d Switch 2: present vi2 native images and capture frames
vi2 229 composites the presented native image (block-linear RGBA8 in the
console's GOB layout, from changes.patch) at its SMMU address, which the GPU
memory registry now records per mapped range. EDEN_NX2_FRAME_CAPTURE=<dir>
saves every 120th presented frame as a TGA for hidden test runs. Also mirrors
releases for every two-page gsv semaphore region and logs gsv sub 101 ranges.
2026-10-27 20:53:14 -04:00
Takoroka
0fbf68fa15 Switch 2: vi2 present/cancel replies and syncpt QueryCounter
vi2 229/228 (PresentClientBuffer/CancelClientBuffer) reply with the mask of
slots the client may acquire next; syncpt 103 (QueryCounter) returns the host1x
value of ~counter. Names and reply shapes from changes.patch. Title 4 now runs
its render loop, presenting window images 1-3 in turn (730 GPU submissions in
60 s); nothing is shown yet.
2026-10-27 19:49:20 -04:00
Takoroka
f7c3638d6e Switch 2: native memory/images, GPU-accessible attribute, TSG subcontexts, syncpoint shim
- gsv 111/112/114/423/429/430/314/315/435 track native memory and images with
  real ids (meanings from changes.patch); 1510/435 use its block-linear layout.
- svc 0x80 sets a real GpuAccessible (0x20) memory attribute (from changes.patch).
- Characteristics report TSG subcontexts (flag 22, 64 per TSG at 0xb4); NvRm
  otherwise allows one subcontext and a second NVN queue fails its setup.
- Syncpoint shim: flag 26, address-space ioctl 0xB, and GPU reads of the shim
  page return guest syncpoint values (scheme from changes.patch).
- EDEN_NX2_IPC_TRACE also logs TIPC commands; gdbrsp.py watch/mem improvements.
2026-10-27 19:30:20 -04:00
Takoroka
ac3c8d25cd Switch 2 (title 1): syncpt handshake, gpu user/gsv partitions
Newer SDKs open the syncpt session with TIPC 0(u64) and need it echoed, and
query the GPU address space partitions with gpu 201/202 instead of 203. With
these and the larger memory budget, title 1 reaches its main loop and the same
empty-command-buffer stop as title 4.
2026-10-27 17:46:02 -04:00
Takoroka
5fada8e590 Switch 2 GPU memory handles and mappings at requested addresses
nx2:gpu 101 (CreateGpuAccessibleMemory) returns real GpuMemoryHandles; 211
(NormalMapGpuMemory4K) maps handle+offset at the requested GPU address,
including sparse regions, through Nx2GpuMemoryRegistry::MapAt (SMMU ranges are
reused). 102/213/214 complete through their job-slot events. gdbrsp.py waits
for a real thread before driving the stub and gains a write-watch op. Notes
record the current stop: an NVN command buffer with no command memory.
2026-10-27 17:39:54 -04:00
Takoroka
f756fe05f7 Switch 2: aud:u audio, REv revision tag, job-slot events, open-file limit
- aud:u (nn::audio::CreateUserClientSessionByHipc) command 2 returns Eden's
  IAudioRendererManager; the renderer accepts Switch 2's 'REv?' update tag by
  comparing revision numbers.
- nx2:gpu sub 211 signals the job slot in request word 17, not word 2; mapping
  jobs no longer stall once the SDK rotates slots.
- eden-cli raises the CRT open-file limit (_setmaxstdio(8192)) like the Qt
  frontend, so loose RomFS folders don't run out of handles.
- Per-mapping GPU logs moved to Debug.
2026-10-27 17:21:19 -04:00
Takoroka
50de2d4e7e Switch 2: window image sizes, queue semaphores, built-in fonts, memory budget
- gsv 1510 CalculateRequirements: block-linear size/alignment for window images.
- nvhost-gpu: Switch 2 channel event 7 is a real (unsignalled) event.
- Puller mirrors NVN2 queue semaphore releases into the page the CPU and GPU
  wait on (the first two-page nx2:gpu region); EDEN_NX2_METHOD_TRACE logs methods.
- pl:u 2000/2010 GetBuiltInFontSharedMemory/GetBuiltInFontData serve plain TTF
  copies of the shared fonts.
- Switch 2 processes count the alias region in their max memory, so the game's
  nninitStartup heap (total - 6.3 GiB) has room for its sound heap.
- gdbrsp.py: interrupt, threads, selthread, hits, continue_async, sleep.
2026-10-27 17:04:06 -04:00
Takoroka
563e727332 Switch 2 GPU: syncpt server, identity GPU mappings, Ampere classes, submit fences
- gsv 204: real syncpoint shared page (values mirrored from host1x, armed waits
  acknowledged by a 500us poller); first handle is the writable request event.
- syncpt 22/201/202: per-slot events signalled through host1x guest actions.
- nx2:gpu sub 101 memory is identity-mapped (GPU VA == CPU VA) into every
  nvhost-as-gpu GMMU via Nx2GpuMemoryRegistry; SMMU physical range widened to
  34 bits for the 10/12 GiB layouts.
- Puller runs Ampere 3D/compute/copy classes on the Maxwell engines; class 0 unbinds.
- Turing+ macros are skipped (Eden only has the Fermi macro ISA).
- Submits with increment_value get Eden-side syncpoint increments, since NVN2
  signals completion with semaphore releases only.
2026-10-27 16:19:35 -04:00
Takoroka
0d679f770e nvdrv: Switch 2 GetEngineInfo, TSG flag, Ampere object classes, channel ioctl passthrough
Once an nx2 NvRm identifies itself (0xD0-byte characteristics), nvhost-gpu and
nvhost-ctrl-gpu answer unknown ioctls with a logged input echo instead of
NotImplemented, ctrl-gpu reports GR + async-copy engines, and Ampere class numbers
(and class 0) map onto Eden's Maxwell object slots. gdbrsp.py gains trace/flow/
breakwhen/fp helpers.
2026-10-27 15:54:37 -04:00
Takoroka
fb7323f25c nvdrv: stub device for nvgpu nodes Switch 1 never had
Unknown /dev/nvhost-* nodes (first: /dev/nvhost-tsg-gpu, opened by the
Switch 2 NvRm during NVN device init) open as nx2_stub_device: every
ioctl succeeds with the input echoed and the rest zeroed, and is logged.
With this NVN device init completes and the title reaches
nn::wsi::ounce::native::NativeWindow::Acquire (first frame).
2026-10-27 15:27:35 -04:00
Takoroka
7cb5831340 Switch 2 GPU memory: svc 0x80, gpu sub-session jobs, VM range, SM 0x808
- svc 0x80 (address, size, mask 0x20, attr 0x20) marks memory GPU
  accessible for nn::gpu::sdk::CreateGpuAccessibleMemory; accept it.
- gpu 22's sub-session is served by the gpu object; sub 101 registers
  memory, sub 211 submits a job whose id event is signalled at once.
- gpu 203 reports [0x8000000, 0xC000000000) as the in-process
  VirtualMachine range that serves AllocSpace (NVN reserves fixed VA at
  0x8000000 up to 512 GiB).
- Report SM 0x808: NVN2's engine class table is only returned for it.
With this NVN device init allocates its GPU memory and opens
/dev/nvhost-tsg-gpu.
2026-10-27 15:17:39 -04:00
Takoroka
ff097d4c30 nvdrv: Switch 2 GPU address-space layout; gpu 33/203
- AllocAsEx from Switch 2 NvRm passes flags 5, no big page size, range
  [0x8000000, 0xC000000000) and split 0 (small pages only). Treat split 0
  as small pages up to the end, keep a 4 GiB big-page region after it, and
  give that allocator an absolute limit (Eden's length-as-limit breaks once
  the split is past the region length).
- gpu TIPC 33 returns a count, 203 a kind plus a VA range used by
  nn::gpu::sdk::CreateGpuAddressSpace.
- gdbrsp.py: unbreak, step, breaklr, unbreakpc, fp (frame walk), trace.
2026-10-27 14:57:51 -04:00
Takoroka
b2c084edcc nvdrv: serve Switch 2 nvsrv with Eden's nvdrv; Ampere characteristics
- gsv 1402's nvsrv session speaks the nvdrv INvDrvServices protocol;
  serve it with an NVDRV on the shared module, initialised for the
  calling process (Switch 2 doesn't call Initialize).
- GetCharacteristics3 callers asking for the 0xD0-byte Switch 2 layout
  get chip 0x17E (Ampere; the Switch 2 NvRm rejects Maxwell for NVN),
  Ampere classes, and s16 interface versions at 0x70..0x80.
- After that, unknown nvhost-ctrl-gpu Ioctl3 commands from such callers
  return a zeroed success (logged).
2026-10-27 14:28:53 -04:00
Takoroka
be9435e691 service: correct TIPC data replies; vi2 timestamp recorder count
ResponseBuilder::Push(Result) writes the CMIF two-word result, so TIPC
data pushed after it landed one word late and outside the copied size;
clients read zeros. TipcReplyWords writes the one-word TIPC result and
the data. vi2 TIPC 5 returns 7 (LayerHistory needs 7 recorders). With
this the title creates its layer and goes on to hid/acc/aoc and RomFS
asset loading.
2026-10-27 14:13:03 -04:00
Takoroka
ccd3885a62 service: Switch 2 vi2 placeholder session (gsv 305)
gsv 305 returns the session nn::vi2::sdk::Initialize keeps. Reply shapes
read from the SDK: TIPC 1 -> u32 < 0x400, 3 -> u32 < 8, 11/31/32 -> one
handle then result (events here). With this nn::vi::Initialize returns and
the title opens the default display and starts creating a layer.
2026-10-27 14:00:36 -04:00
Takoroka
f493daaac2 service: Switch 2 GPU placeholder session (gsv 497)
gsv 497 returns the session nn::gpu::sdk::BootWithRemoteMemory keeps.
On it: TIPC 11 returns an id range, 12(id) returns that id's event, 21(id)
starts an operation the SDK then waits for (signalled at once here), 22
returns another session. With this nn::gs::sdk::BootGraphicsSystem
returns and boot moves on to nn::vi.
2026-10-27 13:56:54 -04:00
Takoroka
6e57c2f643 service: Switch 2 nvsrv and syncpt placeholder sessions behind gsv
- gsv 1402 returns an nvsrv session (handle at word 3, result at word 4);
  nn::nvsrv::BootWithRemoteMemory keeps it.
- gsv 202 returns a syncpt session; gsv 204 takes two transfer memories
  (0x1000 RW, 0x2000 RO) and must leave a header in the RO one (version 1,
  count, five region offsets) and return two event handles.
- syncpt TIPC 1 returns a u32 < 0x400 (32 here).
RequestParser doesn't skip TIPC handle words, so 204 reads raw data words.
2026-10-27 13:48:52 -04:00
Takoroka
d2b28c7620 am: GetPseudoDeviceId without control metadata
Loose ExeFS boots have no control.nacp, so GetPseudoDeviceId returned
ResultUnknown and the title aborted. Seed from the program id instead.
2026-10-27 13:36:58 -04:00
Takoroka
9f1d8357c0 am: placeholder Switch 2 graphics-system (gsv) session
ISelfController 2000 hands nn::gsv::BootWithRemoteMemory a raw session
handle it then speaks TIPC on (4, 11, 101, 1501, 1502, 1402 during boot).
Return a session to INx2GraphicsSystemSession, which answers every
command with an empty success and logs it. ReturnRawSession creates the
session outside the caller's domain, since gsv wants a real handle.
2026-10-27 13:32:41 -04:00
Takoroka
f7be327f97 kernel: stub Switch 2 svcGetInfo 31/32 (remote memory)
nn::os::GetRemoteMemoryUsage returns {id 31, id 32}; nn::gsv and
nn::nvsrv BootWithRemoteMemory use it while booting the graphics
system. Return 0 for both for now (logged).
2026-10-27 13:32:40 -04:00
Takoroka
4e5274820d service: EDEN_NX2_IPC_TRACE and EDEN_NX2_AUTO_STUB switches
IPC trace logs every dispatched command and non-zero result words.
EDEN_NX2_AUTO_STUB auto-stubs unknown commands without relying on the
use_auto_stub setting, which eden-cli's config rewrite resets.
2026-10-27 13:26:46 -04:00
Takoroka
3f5bdb81f9 am: Switch 2 graphics-scale interface and IApplicationFunctions 321
IApplicationProxy 60 returns the interface nn::oe::GetCurrentGraphicsScale
uses; its command 10 must return 10, 20 or 30, so return 10. Other
commands on it are auto-stubbed (nx2: prefix). IApplicationFunctions 321
is called right after 320; stub it.
2026-10-27 13:26:44 -04:00
Takoroka
1a54a1aea7 loader: give loose ExeFS boots a RomFS and an fs registration
The ExeFS directory loader never set its romfs member and, when used on
its own, never registered the process with the FileSystemController, so
fsp-srv SetCurrentProcess failed with ResultTargetNotFound (2002-1002).
Build the RomFS from a romfs/ directory next to exefs/ (or a .romfs file
in exefs/), and register the process when the loader isn't wrapped by
the NCA/NSP loaders.
2026-10-27 13:26:37 -04:00
Takoroka
640b42c818 am: stub IApplicationFunctions 320 (called by Switch 2 titles) 2026-10-27 12:57:38 -04:00
Takoroka
a9bd43b9d1 kernel: optional SVC trace (EDEN_NX2_SVC_TRACE=1) 2026-10-27 12:52:40 -04:00
Takoroka
fb516c2ce2 kernel: fold Switch 2 virtual cores 4/5 onto emulated cores
Switch 2 titles get core mask 0x3f and nn::oe creates a thread on core 5.
Eden emulates four cores, so fold virtual cores 4..7 onto 0..3 in
CreateThread and SetThreadCoreMask (after validating against the real
process mask).
2026-10-27 12:52:39 -04:00
Takoroka
6a58a33930 am: Switch 2 appletOE/IApplicationProxy entry points
- appletOE command 10 opens the application proxy (same arguments as 0).
- IApplicationProxy commands 40/50/.../90 are new getters; return an
  INx2StubInterface (nx2_stub_interface.h). Interfaces whose name starts
  with nx2: answer every call with an empty success and log it.
2026-10-27 12:52:39 -04:00
Takoroka
f8e3da63f5 kernel: svcGetInfo 33 is a page granule; give 29/30 a real region
The SDK checks module address/size against (id33 - 1) when initialising
DSOs, so id 33 is a page granule: return 0x1000. Report ids 29/30 as the
upper half of the alias region (a plausible VAMM address-space region,
backed through MapPhysicalMemory) instead of an empty region.
2026-10-27 12:52:39 -04:00
Takoroka
b71771c691 kernel: stub Switch 2 svcGetInfo ids 29, 30 and 33
nnosInitialize queries ids 29/30 between the alias (2/3) and ASLR (12/13)
regions and aborts if they fail; report an empty region after the alias
region. VammManager::Initialize (enabled when the system resource size is
non-zero) queries id 33 and passes it to MapPhysicalMemory as a size, so
return 2 MiB. Both are logged as stubs; the real meanings are unknown.
2026-10-27 12:20:28 -04:00
Takoroka
b2f11310f5 npdm: parse the Switch 2 ACID layout
Switch 2 ACID blocks have a 0x300-byte signature/key area (Switch 1:
0x200), so the ACID header starts 0x100 bytes later. Without this the
FAC offset was garbage and loading failed with ErrorBadFileAccessControl.
Also read FAC/FAH relative to their ACID/ACI block, as the format (and
the existing KAC read) does.
2026-10-27 12:00:22 -04:00
Takoroka
47a7f5c495 loader: load a loose ExeFS when given its main
'main' is also a valid NSO, so IdentifyFile picked the single-NSO loader,
which skips main.npdm, rtld and the sdk modules and then crashes writing
into an uninitialised process. Prefer the ExeFS directory loader when the
file is named main and sits in an ExeFS.
2026-10-27 12:00:22 -04:00