Skip to content

Implement syscall 0x83 (FindAddress) with kernel tests#93

Merged
ran-j merged 1 commit intoran-j:mainfrom
Whoneon:issue-90-syscall-0x83
Mar 6, 2026
Merged

Implement syscall 0x83 (FindAddress) with kernel tests#93
ran-j merged 1 commit intoran-j:mainfrom
Whoneon:issue-90-syscall-0x83

Conversation

@Whoneon
Copy link
Contributor

@Whoneon Whoneon commented Mar 4, 2026

This PR implements numeric syscall 0x83 (FindAddress) in the runtime kernel syscall dispatcher and adds proper tests. This emerged due to issue #90

Changes

  • ps2xRuntime/src/lib/ps2_syscalls.cpp
    • added dispatch:
      • case 0x83: FindAddress(...)
  • ps2xRuntime/src/lib/syscalls/ps2_syscalls_system.inl
    • implemented FindAddress:
      • inputs: a0=start, a1=end (exclusive), a2=target
      • scans table as 32-bit words
      • returns matching entry address in v0
      • returns 0 if not found
      • supports KSEG alias normalization (addr & 0x1FFFFFFF) for stronger match behavior
  • ps2xTest/src/ps2_runtime_kernel_tests.cpp
    • added tests for:
      • found entry
      • KSEG alias match
      • not-found returns zero

Why this shape

  • syscall number mapping follows PS2SDK (__NR_FindAddress = 0x83).
  • behavior inferred from generated wrappers/call sites that pass (start, end, symbol) and require v0 as an address.
  • the implementation is agnostic (no game-specific constants/workarounds).

Out of scope

  • 0x74 mapping/semantics (SetSyscall vs current runtime mapping) is intentionally not changed here and will be handled in a separate PR.

// - a1: table end (exclusive)
// - a2: target address to locate inside the table (word entries)
// Returns the guest address of the matching word entry, or 0 if not found.
void FindAddress(uint8_t *rdram, R5900Context *ctx, PS2Runtime *runtime)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be thread safe ?

@ran-j ran-j merged commit 9e4fd79 into ran-j:main Mar 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants