Commit Graph
537 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 a91448b318 sceKernelThread: actually accumulate runForClocks
nt.runForClocks was zeroed when a thread was created and copied out by
sceKernelReferThreadStatus, but nothing ever added to it, so every thread
reported having run for zero time forever.

Crazy Taxi: Fare Wars uses it as a liveness check. Its music state machine
samples the mp3 thread's run time once every 60 frames and compares it with
the previous two samples; when it doesn't move it concludes playback is
wedged, sets the stop bit, and the thread tears itself down and exits. The
game restarts it, and about a second later decides it's wedged again - custom
soundtracks restarted roughly once a second forever, whatever the file.

Bill the time since the previous switch to the outgoing thread, which is
exactly the thread that was running for it. The field is already part of the
serialized thread struct, so savestates don't change format; the timestamp
itself is re-based on load rather than saved, and only on load - saving runs
a measure pass and a write pass, and re-basing in those would discard the
time the running thread had accumulated since the last switch, letting a save
change what the game can observe.

Risk: this runs on every context switch, the hottest path in the scheduler.
It adds one CoreTiming read and a 64-bit add. Games that poll thread run
times will now see them move, which is correct but is new behavior.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 12:48:22 -06:00
Henrik Rydgård 0f94e01241 HLE: Clamp the wait timeout remaining time to zero
CoreTiming::UnscheduleEvent returns the scheduled time minus the current time,
which is negative when the event is overdue but hasn't been processed yet - the
exact situation when a wait is satisfied right around its own timeout. Only the
semaphore clamped it; everywhere else we wrote (u32)cyclesToUs(negative) into
the game's timeout variable, i.e. a huge bogus "remaining time".

Pulled the shared shape into HLEKernel::WriteRemainingTimeout so it can't drift
apart again - event flags, mbx, fpl, vpl, msgpipe, mutex, lwmutex and semaphore
all go through it now. The two thread-end sites keep their own copy since they
unschedule even when the game passed no timeout pointer, and sceUsb just gets
the clamp.
2026-09-04 18:10:10 -06:00
Henrik Rydgård a0ecf545a6 Implement or stub assorted functions the VSH is calling 2026-08-21 10:56:06 +02:00
Henrik Rydgård 31decccb9a Style and comment settings. Surface a setting in the ImDebugger. 2026-08-20 01:05:19 +02:00
Henrik RydgårdandClaude Sonnet 5 43dccd5903 HLE: implement assorted stubs and minor functionality
This is stuff encountered in the VSH boot research.

sceRtc_driver, scePower_driver, sceImpose_driver, ThreadManForKernel funcs,
sceRtcGetAlarmTick, sceHprm_driver/sceHprmReadLatch

sceVshBridge_Driver imports sceKernelResumeDispatchThread, SuspendDispatchThread,
and NotifyCallback from ThreadManForKernel, but they were only registered under
ThreadManForUser. Added sceKernelGetUserLevel and sceKernelIsUserModeThread (new).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-19 18:38:03 +02:00
Henrik RydgårdandClaude Sonnet 5 21b7ce7392 Expose EventFlag/Mutex/Semaphore/MsgPipe/Callback in their headers
These KernelObject subclasses (and their Native* status structs) were
private implementation details of their respective .cpp files. Move them
into the matching .h instead, so external code - specifically the upcoming
WebSocket kernel-object introspection endpoints - can read a live object's
state directly via kernelObjects.Get<T>()/Iterate<T>(), the same way
PSPModule/PSPThread already can. Read-only by convention: nothing outside
each file should call DoState() or otherwise mutate these; the fields are
public here for that file's own pre-existing use, not an invitation to
write from elsewhere.

To avoid pulling each type's full dependency set (Memory::, BlockAllocator,
CoreTiming, HLEKernel::...) into headers many other files include, non-trivial
method bodies (DoState, and MsgPipe's buffer/wait-list management) are
declared in the header but still defined out-of-line in the .cpp, same as
before - only genuinely trivial one-liners went inline.

KernelObjectPool also gains IterateAll(), a type-agnostic sibling of the
existing Iterate<T>() - walks every live kernel object regardless of type,
for a coarse "what's alive right now" overview.

No behavior change - this is a pure visibility/declaration-vs-definition
move, not new functionality. That lands in a follow-up commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 16:01:23 +02:00
Henrik Rydgård eb0813c0e3 Add a utility function for all the ABIs to call functions with a pointer arg. Use to call Advance from the JIT with the MIPSContext. Indent some code better. 2026-08-13 08:09:30 +02:00
Henrik Rydgård e9a3449ede More MIPSState * plumbing (manual) 2026-08-12 14:02:19 +02:00
Henrik Rydgård 0596ee97f6 More memory access cleanup 2026-08-11 20:14:01 +02:00
Henrik Rydgård 3bd41376da More memory cleanup 2026-08-11 20:12:10 +02:00
Henrik Rydgård cd052ea640 Adjust the level of Claude-based paranoia here and there 2026-08-11 20:08:01 +02:00
Henrik Rydgård 7824f69020 Code style updates 2026-08-10 11:17:58 +02:00
Henrik Rydgård e2bc017112 More removals of Read_U32 2026-08-10 11:17:45 +02:00
Henrik Rydgård 788150c28e Fix out-of-bounds reads in PGF font parsing
PGF::ReadPtr walked four length-prefixed tables and computed table sizes
before any bounds check, and used signed 32-bit size math that could
overflow, allowing a crafted font to read past the input buffer.

- Validate the total size of all tables up front using 64-bit math.
- Check the rev3 extra header fits before reading it.
- Cap charPointerLength/charMapLength/shadowMapLength to avoid absurd
  allocations.
- Bounds-check glyph data offsets before reading each glyph.

Also throw in a warning fix
2026-08-01 11:57:27 +02:00
Henrik Rydgård a7dc184613 Reapply "Implement exit callbacks. Attempt to solve #21828"
It was a mistake to revert c4d3cc8 , need to take savestates into
account

This reverts commit d5cec86933.
2026-07-08 19:45:42 +02:00
Henrik Rydgård d5cec86933 Revert "Implement exit callbacks. Attempt to solve #21828"
This reverts commit e4d3cc841c.
2026-07-08 18:09:09 +02:00
Henrik Rydgård e4d3cc841c Implement exit callbacks. Attempt to solve #21828 2026-06-15 12:12:57 +02:00
Henrik Rydgård 634b9dba9b Add some new NIDs, update some comments 2026-06-15 08:16:40 +02:00
Henrik Rydgård 3f6582aa7b Minor logging changes 2026-05-30 19:07:59 +02:00
Henrik Rydgård 3ecb54e70a More tweaking of gamelist icons 2026-02-11 01:24:11 +01:00
Katharine Chui 326448636b Run module_start of plugins before starting boot module 2025-06-13 23:29:49 +02:00
Henrik Rydgård ba148e5ec7 JIT/IRJit: Delete an old "function preloading" experiment
This caused some confusion while trying to debug #20502
2025-06-11 15:45:18 +02:00
Henrik Rydgård 61a89de6a7 Smash Court Tennis 3 unprintable thread name hack 2025-05-26 18:04:46 +02:00
Henrik Rydgård 15d24806bb sceKernelThread: Make a bunch of globals static 2025-05-25 12:40:16 +02:00
Henrik Rydgård 343ca2600a Add a developer setting to disable individual HLE modules, allowing them to be loaded properly.
Some games survive with a loaded sceAtrac, and start talking to
sceAudioCodec instead, the underlying library, though unsuccessfully
since it's not properly implemented yet.
2025-04-02 10:19:24 +02:00
Henrik Rydgård 2bfe327dbd Expose PSPThread in the same manner 2025-03-31 10:24:03 +02:00
Henrik Rydgård 644f5e4e6c Expose PSPModule (so the debugger can access it later) 2025-03-31 09:56:08 +02:00
Henrik Rydgård 0f840e6240 Move JPEG error codes to the big enum, some include cleanup 2025-03-21 20:44:46 +01:00
Henrik Rydgård bb436cda8f Reimplement a lot of logic, implement loop streaming properly 2025-03-18 09:36:33 +01:00
Henrik Rydgård af8d14c546 Buildfix 2025-03-08 23:56:01 +01:00
Henrik Rydgård 89e031fb8a Logging cleanup 2025-03-08 23:39:22 +01:00
Henrik Rydgård 881e88268f Fix log-stack problem in kernel 2025-03-08 23:37:48 +01:00
Henrik Rydgård 0f9c97c2a0 Another big batch of logging cleanup 2025-03-05 17:02:46 +01:00
Henrik Rydgård ad2791a9cf More HLE logging cleanup 2025-03-05 17:02:46 +01:00
Henrik Rydgård cb180bf781 A lot of log cleanup. It's quite useful as a forcing function to find missing logs. 2025-03-05 17:02:46 +01:00
Henrik Rydgård 36fa0fe343 Update logging in sceKernelResumeThread 2025-03-02 11:24:51 +01:00
Henrik Rydgård 28b2c7f540 HLE log rename part 1: Remove duplicate log functions. Return type should be determined by metadata. 2025-01-29 09:45:39 +01:00
Henrik Rydgård 16dcb9ee8a And more 2025-01-20 12:20:21 +01:00
Henrik Rydgård 26547e2629 More fixes 2025-01-20 12:20:21 +01:00
Henrik Rydgård 2b5b2a8fa5 Add a "pedantic" self-check mode, improve logging some more. 2025-01-20 12:20:21 +01:00
Henrik Rydgård f962fb0386 Enable checking the format string, fix some issues 2025-01-19 16:51:05 +01:00
Henrik Rydgård bb914ca4bf More kernel logging cleanup 2025-01-19 15:36:59 +01:00
Henrik Rydgård 5f5ad32f7e Start cleaning up logging 2025-01-19 12:10:57 +01:00
Henrik Rydgård 20a17a0e8d Reorganize DebugInterface etc a bit.
KernelThreadDebugInterface no longer has a useless copy of a MIPSDebugInterface.
2024-12-12 18:54:46 +01:00
Henrik Rydgård 739a32324d Thread view: Show wait type 2024-12-08 11:13:21 +01:00
Henrik Rydgård 41eeb491e7 Replace a few more sprintf with snprintf 2024-10-15 15:45:19 +02:00
Henrik Rydgård 5939270d2c Log: Split out StdioListener from ConsoleListener, making the second Win32-only. 2024-07-21 13:55:40 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Unknown W. Brackets 32feb82d16 HLE: Capture better allocation names.
We know which FPL, so don't just say "FPL".
2023-09-02 22:55:45 -07:00
Unknown W. Brackets a7b7bf7826 Global: Set many read-only params as const.
This makes what they do and which args to use clearer, if nothing else.
2022-12-10 21:13:36 -08:00