Skip to content

Implement SetSyscall (syscall 0x74) with safe override/fallback dispatch#94

Open
Whoneon wants to merge 2 commits intoran-j:mainfrom
Whoneon:fix-syscall-0x74-setsyscall
Open

Implement SetSyscall (syscall 0x74) with safe override/fallback dispatch#94
Whoneon wants to merge 2 commits intoran-j:mainfrom
Whoneon:fix-syscall-0x74-setsyscall

Conversation

@Whoneon
Copy link
Contributor

@Whoneon Whoneon commented Mar 4, 2026

This PR implements numeric syscall 0x74 as SetSyscall, with runtime override support for numeric syscalls. This was discussed before in #93

Motivation

Generated code from Burnout 3 (SLUS 210.50) shows explicit syscall usage with $v1 = 0x74 (SetSyscall). This has been confirmed by looking at PS2Tek and ps2sdk syscallnr.h and using them as SoT

What changed

  • 0x74 now dispatches to SetSyscall.
  • Added a thread-safe override table: syscallIndex -> handlerAddress.
  • Added pre-dispatch override resolution:
    • if override exists and can be invoked, use it
    • if invocation fails/missing target, fall back to built-in numeric syscall handling
  • Cleared override table in runtime teardown.
  • Added SetSyscall to the call-list X-macro.

Tests

Added kernel runtime tests that verify:

  1. override install + execution + returned v0
  2. override clear and return to built-in behavior
  3. fallback to built-in when override target is not registered

SetVSyncFlag(rdram, ctx, runtime);
return true;
case 0x74:
RegisterExitHandler(rdram, ctx, runtime);
Copy link
Owner

Choose a reason for hiding this comment

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

Please don't remove exit. Move it to correct syscall id

setReturnS32(ctx, 0);
}

static bool dispatchSyscallOverride(uint32_t syscallNumber, 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.

Can you explain what is this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It checks whether a given numeric syscall has a runtime override registered. If found and is callable, the function forwards execution there and returns true. If no valid override exists, it returns false

@ran-j
Copy link
Owner

ran-j commented Mar 6, 2026

I was playing around with this and I think I found a bug. I will confirm later.

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