Commit Graph

2005 Commits

Author SHA1 Message Date
Dean 2d21b3badc
Merge pull request #541 from DotDebian/fix/nanosleep-errors
fix(libkernel): report invalid nanosleep requests through errno and the sce error codes
2026-10-05 10:31:42 +13:00
Dean c457e756a5
Merge pull request #538 from DotDebian/feat/ampr-command-buffer-markers
feat(ampr): implement the command buffer markers
2026-10-05 10:23:03 +13:00
Dean 6a705bc4bd
Merge pull request #536 from DotDebian/feat/font-get-resolution-dpi
feat(font): implement sceFontGetResolutionDpi
2026-10-05 10:22:47 +13:00
Phi1ow 1cd34c232d feat(pad): implement scePadSetAngularVelocityDeadbandState
scePadSetAngularVelocityDeadbandState was the last throwing stub in libScePad. It toggles a
dead-band filter on the controller's angular-velocity (gyro) readings; the reading path does
not apply that optional filter, so the call succeeds and does nothing, as it does in shadPS4.

Extends the existing guest_pad test with the two enable/disable calls. It fails on main (the
stub throws) and passes with the change.
2026-10-04 23:19:37 +02:00
Dean 23f20ebc40
Merge pull request #156 from Pacuka/fix/pthread-mutex-types
fix(libkernel): default mutexes to error checking and add the adaptive type
2026-10-05 10:15:22 +13:00
Phi1ow ce6b26fadb feat(razor): implement the libSceRazorCpu CPU profiler stubs
libSceRazorCpu is the CPU-side instrumentation for the Razor capture tool. AnyPS5 does not host
that tool, so the instrumentation does nothing and succeeds, which is also what shadPS4 does:

- sceRazorCpuIsCapturing -> 0 (no capture is in progress, so titles skip their profiling paths)
- sceRazorCpuJobManagerDispatch / sceRazorCpuJobManagerJob / sceRazorCpuJobManagerSequence -> 0

These only feed the profiler; they do not affect execution. Adds a CMakeLists.txt so the library
can carry its guest test.

New test core/libs/tests/GuestRazorCpu.cpp checks the four return values; it fails on main (the
functions throw) and passes with the change.
2026-10-04 23:12:52 +02:00
Dean 76c34275b4
Merge pull request #347 from Pouare514/fix/kernel-nooverwrite-win
fix(libkernel): support NoOverwrite mappings on Windows
2026-10-05 10:11:34 +13:00
Dean 9506815f98
Merge pull request #468 from Pacuka/feat/ajm-opus
feat(ajm): decode Opus (codec 24) through FFmpeg
2026-10-05 10:11:08 +13:00
Phi1ow 7854fb6bff feat(errordialog): implement the libSceErrorDialog state machine
The six libSceErrorDialog exports were throwing stubs. They now implement the dialog's
NONE -> INITIALIZED -> RUNNING -> FINISHED state machine without a visible window, so a title
that opens an error dialog and waits for it never blocks:

- sceErrorDialogInitialize -> INITIALIZED, or 0x80ED0002 if already initialized
- sceErrorDialogOpen -> checks the state and the 16-byte parameter, then RUNNING
- sceErrorDialogUpdateStatus -> turns RUNNING into FINISHED and returns the status
- sceErrorDialogGetStatus -> returns the status
- sceErrorDialogClose -> FINISHED, or 0x80ED0005 when no dialog is running
- sceErrorDialogTerminate -> NONE, or 0x80ED0001 when not initialized

Re-opening is allowed once a previous dialog has finished. The status values and error codes
are the documented SCE error-dialog ones. Adds a CMakeLists.txt so the library can carry its
guest test.

New test core/libs/tests/GuestErrorDialog.cpp drives the whole state machine (the
not-initialized and already-initialized errors, the state and parameter checks of open,
open/update/close and re-open after finish). It fails on main (the stubs throw) and passes
with the change.
2026-10-04 22:33:43 +02:00
Phi1ow be59a9e7e9 feat(http): implement sceHttpCreateRequest2, sceHttpsEnableOption, sceHttpsLoadCert and sceHttpGetLastErrno
Four more libSceHttp exports, following the library's existing "no network emulated" model:

- sceHttpCreateRequest2 -> a new handle, like sceHttpCreateRequestWithURL2
- sceHttpsEnableOption -> 0, the counterpart of the existing sceHttpsDisableOption
- sceHttpsLoadCert -> 0 (certificates are accepted and ignored; no TLS is performed)
- sceHttpGetLastErrno -> 0 (no request reaches the network, so no errno is recorded); a
  null output pointer returns ERROR_INVALID_VALUE, like the other getters in this file

Signatures follow the public OpenOrbis SDK headers. GuestHttp is extended to cover the four
functions; the new assertions fail without the change (the symbols are undefined).
2026-10-04 22:04:13 +02:00
Phi1ow 75c2ea8548 feat(sysmodule): implement sceSysmoduleLoadModuleInternal and sceSysmoduleUnloadModuleInternal
Two exports were missing. System modules are linked statically, so load and unload are
reference counts over the known module table, exactly like the existing
sceSysmoduleLoadModuleInternalWithArg and sceSysmoduleUnloadModule:

- sceSysmoduleLoadModuleInternal(uint32_t) -> increments the module's load count, returns 0
- sceSysmoduleUnloadModuleInternal(uint32_t) -> decrements it, or 0x80A90003 when the module
  was not loaded

Unknown or zero ids throw, like the sibling internal loader. Adds a CMakeLists.txt so the
library can carry its guest test. Signatures follow the public OpenOrbis SDK headers.

New test core/libs/tests/GuestSysmodule.cpp loads a module twice, unloads it twice and checks
the not-loaded error on a third unload; it fails without the change (the symbols are
undefined) and passes with it.
2026-10-04 21:56:29 +02:00
Pouare514 89cd75e15f fix(libkernel): idempotent fixed virtual reservation over registered range 2026-10-04 21:02:15 +02:00
DotDebian d98bbcd5bb fix(libkernel): report invalid nanosleep requests through errno and the sce error codes
nanosleep and _nanosleep forwarded the result of sceKernelNanosleep, which
returned -1 for a rejected request: errno was never set, and the sce call
returned a value that is not an sce error. A request with negative seconds
was rejected as well, where FreeBSD's kern_nanosleep returns 0 without
sleeping.

nanosleep and _nanosleep now return -1 with errno set to EINVAL when tv_nsec
is outside [0, 1000000000) and to EFAULT for a null request;
sceKernelNanosleep returns the matching SCE_KERNEL_ERROR code. A request
with valid nanoseconds and negative seconds returns 0 at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 18:19:53 +02:00
DotDebian 638d3802ad feat(ampr): implement the command buffer markers
sceAmprCommandBufferPushMarker, PushMarkerWithColor, PopMarker, SetMarker
and SetMarkerWithColor record a marker command, and the matching
sceAmprMeasureCommandSize functions return its size. The APR executor
skips markers, as it does a nop.

Signatures follow the ampr_emu reimplementation of libSceAmpr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 18:10:16 +02:00
DotDebian cd6c20f783 feat(font): implement sceFontGetResolutionDpi
Report the horizontal and vertical resolution kept in the font handle's
style block, as set when the font is opened (72 dpi) or by
sceFontSetResolutionDpi. Error handling follows the other handle getters:
an invalid handle or two null outputs fail and clear the outputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 17:59:31 +02:00
DotDebian f9625f2581 feat(libkernel): implement the pthread_rwlock try and timed lock functions
The POSIX layer only exported init, destroy, rdlock, wrlock and unlock.
pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock,
pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock now wrap the
existing scePthreadRwlock functions and accept the static initializer.

The timed variants take an absolute CLOCK_REALTIME deadline. Like
FreeBSD libthr they try the lock first and only validate abstime when
the lock is not free. A null abstime throws, as pthread_mutex_timedlock
does.

scePthreadRwlockTryrdlock and scePthreadRwlockTrywrlock return EBUSY
when the caller already holds the write lock instead of calling into
std::shared_timed_mutex, where that is undefined behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 17:13:36 +02:00
Pouare514 497a772c5d fix(libkernel): hand arena reservations to NoOverwrite mappings 2026-10-04 16:46:39 +02:00
DotDebian 624eeac4c5 test(shader): cover v_fmac_f32, v_fmamk_f32 and v_fmaak_f32 and count them as decoded
VOP2 0x2b, 0x2c and 0x2d decode to the opcodes of v_mac_f32, v_madmk_f32
and v_madak_f32 and differ only by the encoding, which keeps them fused.
The progress map derives names from the opcode enum, so it listed the three
fused forms as missing.

The new test decodes the six encodings and checks that the translation
rounds the product separately for 0x1f-0x21, keeps 0x2b-0x2d fused, and
reads the accumulator and the literal from the right operand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 16:36:17 +02:00
Pouare514 2be3860983 fix(tests): flush stdout in QuickFirst so ctest pipe captures handler output 2026-10-04 15:24:44 +02:00
Pouare514 1cbf3fa8e4 feat(libc): implement at_quick_exit and quick_exit 2026-10-04 15:20:51 +02:00
Pacuka 6814cab9f9 fix(libkernel): map POSIX adaptive mutexes to the adaptive type
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:30:12 +02:00
Pacuka 98f050f879 fix(libkernel): default mutexes to error checking and add the adaptive type
The PS5 libthr (FreeBSD) creates error-checking mutexes by default and has
PTHREAD_MUTEX_ADAPTIVE_NP (type 4); relocking an error-checking or adaptive
mutex returns EDEADLK. Default mutexes were Normal and type 4 was mapped to
Normal, so a relock threw instead of returning EDEADLK, which aborted an
Unreal Engine title's recursive directory scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:28:33 +02:00
Pacuka 5ecf80e2f5 feat(ajm): decode Opus (codec 24) through FFmpeg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:26:57 +02:00
Adrià Franch 7e5ce945e1 feat(libSceAudioIn): implement sceAudioInClose and throw for the unverified 0x10 format
Close releases the port and its host device; Input and Close on a port
that is capturing return BUSY. Format codes follow the PS5 SDK bindings
(SharpProspero) and KytyPS5: 1/2 S16 mono/stereo, 0x11/0x12 float.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:39:33 +02:00
Adrià Franch 29aa4f3cdf feat(libSceAudioIn): capture from the host's recording device
sceAudioInOpen validates the port and opens the default SDL recording
device in the requested format; sceAudioInInput returns one grain of
captured samples, padded with silence when the device falls behind and
keeping at most four grains of latency. Without a recording device a
port reports DEVICE_NONE in sceAudioInGetSilentState and delivers
silence at its sample rate.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:37:09 +02:00
Dean Galvin be3f06bfe8 feat(libSceAudioPropagation): render silence for propagated sources
sceAudioPropagationSourceRender takes the system, an array of RenderInfo
descriptors and their count: PPSA21564 and PPSA21567 pass one RenderInfo
{0x010107d6, 0x30} per call, with the source handle at +0x10, its output
buffer at +0x18, the buffer size in bytes at +0x20 and the word 2 at
+0x28, once per audio grain for each propagated source.

Without acoustic propagation a source contributes nothing, so each
output buffer is zeroed for its size. Every RenderInfo is checked first
(descriptor, a live source of this system, a non-empty output), and a
count of 0 or a format word other than 2 throws, as neither has been
observed.
2026-10-04 19:26:06 +13:00
RomainROCH 5211ba115b fix(libc): count wide string precision in output characters 2026-10-04 04:31:26 +02:00
Dean 396b282315
Merge pull request #339 from DotDebian/feat/cpu-time-clocks
feat(libkernel): support the CPU-time clocks in clock_gettime and clock_getres on Windows
2026-10-04 14:21:40 +13:00
Dean e6505d8a93
Merge pull request #312 from RomainROCH/codex/fix-save-memory-metadata
fix(savedata): report memory metadata write failures
2026-10-04 14:13:01 +13:00
Dean 1137cffb72
Merge pull request #429 from RomainROCH/codex/fix-rfc3339-offsets
fix(rtc): reject invalid RFC 3339 timezone offsets
2026-10-04 14:03:23 +13:00
Dean 1964aad443
Merge pull request #428 from RomainROCH/codex/fix-posix-semaphore-limits
fix(libkernel): enforce POSIX semaphore count limits
2026-10-04 14:03:06 +13:00
Dean 12db9a8fcf
Merge pull request #420 from MichonGoddijn231849/fix/ajm-batch-job-size
fix(ajm): a decode job fits the 64-byte batch titles allocate
2026-10-04 14:02:48 +13:00
Dean d0bec2e448
Merge pull request #378 from DotDebian/fix/posix-file-errno
fix(libkernel): return -1 and set errno from the POSIX open, stat, unlink and rmdir
2026-10-04 14:01:57 +13:00
Dean a6cdfa1c7f
Merge pull request #352 from arreina/pr/savedata-delete-dir-name
fix(savedata): reject invalid directory names in sceSaveDataDelete
2026-10-04 14:01:40 +13:00
Dean e5676b3f0e
Merge pull request #315 from RomainROCH/codex/fix-semaphore-overflow
fix(libkernel): avoid semaphore count overflow
2026-10-04 14:01:19 +13:00
Dean e50c18a42d
Merge pull request #314 from RomainROCH/codex/fix-fgetpos-error
fix(libc): propagate file position errors
2026-10-04 14:01:01 +13:00
Dean 1dd1be67e3
Merge pull request #262 from RomainROCH/codex/fix-aligned-delete
fix(libc): release aligned allocations through the application heap
2026-10-04 14:00:42 +13:00
Akhil Moola ac66e70882 feat(libSceAudioPropagation): implement the no-acoustic-propagation path with recovered signatures
The 22 exports used by PPSA21567 take the call shapes recovered from its
call sites (#481): destroys take the system and the object, attribute
setters take a count, SourceCreate takes only an output handle,
UnregisterMaterial only the material.

The system lives in the title's CPU memory (16-byte header, no GPU memory)
and its handle is that address; rooms, portals, sources and materials are
counter handles. Attributes are validated and have no effect; no rays are
requested and sources report no audio paths. Non-empty ray results, path
calculation and audio paths throw, SourceRender stays unimplemented, and
invalid input throws because no error code is known. Objects left when
their system is destroyed become unusable; their later destroy or
unregister is a no-op.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 15:28:36 -06:00
Dean Galvin 6670c52571 fix(libc): run the cleanups of frames that use the C personality
GCC gives C code built with -fexceptions, and cleanup-only functions
after link-time optimization, the C personality __gcc_personality_v0.
The unwinder accepted only its own C++ personality, so an exception
thrown through such a frame was never caught.

libc now provides the C personality, which never catches and installs
the frame's cleanup landing pad in the cleanup phase, and the unwinder
calls it for those frames.
2026-10-04 05:32:55 +13:00
Alexey 87f016b0da
Merge pull request #370 from DotDebian/fix/pthread-attr-get
fix(libkernel): report the thread's priority and affinity from scePthreadAttrGet
2026-10-03 11:02:46 +03:00
Alexey e1bfb3973f
Merge pull request #364 from DotDebian/feat/pthread-barrierattr
feat(libkernel): implement the pthread_barrierattr functions
2026-10-03 11:01:01 +03:00
Alexey a818beedf5
Merge pull request #341 from DotDebian/feat/kernel-cancel-sema
feat(libkernel): implement sceKernelCancelSema
2026-10-03 10:58:13 +03:00
Alexey 9f7e6499bd
Merge pull request #335 from DotDebian/feat/kernel-event-accessors
feat(libkernel): implement the sceKernelGetEvent* field accessors
2026-10-03 10:50:28 +03:00
Alexey 67fd6385e7
Merge pull request #328 from arreina/pr/json-nesting-limit
fix(json2): reject documents nested deeper than 512 levels
2026-10-03 10:35:04 +03:00
Alexey 00193ec66f
Merge pull request #311 from asimplestray/feat/shader-sop1-bitcount64
test(shader): cover 64-bit scalar bit-count ops
2026-10-03 10:01:10 +03:00
Alexey aff499474a
Merge pull request #309 from asimplestray/feat/shader-vopc-const
test(shader): cover VOPC compare constants and ordered F16
2026-10-03 09:58:37 +03:00
RomainROCH 44c9c77a7c fix(rtc): reject invalid RFC 3339 timezone offsets 2026-10-03 04:08:27 +02:00
RomainROCH eae05782af fix(libkernel): enforce POSIX semaphore count limits 2026-10-03 04:03:25 +02:00
Michon 8bbba91a04 fix(ajm): a decode job fits the 64-byte batch titles allocate
Batch jobs were stored as a 72-byte header plus 16 bytes per buffer, so one decode
job took 104 bytes. GTA V initializes its MP3 batches with 0x40 bytes, every
sceAjmBatchJobDecode returned SCE_AJM_ERROR_OUT_OF_RESOURCES and its streamed
music and speech stayed silent. A job is now a 32-byte record, its buffers, and
its parameters only when it has any; the MP3 test decodes through a 64-byte batch.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-03 01:18:56 +02:00
RomainROCH 1a55adfee2 chore(savedata): sync metadata fix with main 2026-10-03 00:09:01 +02:00
asimplestray 51c5e00ba9 test(shader): cover 64-bit scalar bit-count ops 2026-10-02 21:48:23 +00:00
boykopovar 7d40a57d18
Merge pull request #308 from asimplestray/feat/shader-vop3-mad
feat(shader): implement legacy float multiply-add ops
2026-10-02 23:29:05 +03:00
boykopovar 8ff209a865
Merge pull request #300 from Pouare514/feat/libScePlayGoDialog
feat(libScePlayGoDialog): add PlayGo install dialog
2026-10-02 23:08:55 +03:00
boykopovar d098840dbc
Merge pull request #307 from oneandonlydean/feat/avplayer-ffmpeg
feat(avplayer): decode H.264 and AAC with FFmpeg
2026-10-02 23:07:49 +03:00
boykopovar b45d521224
Merge pull request #287 from SP4C3B4R-8/feat/pad-tilt-correction
feat(libScePad): implement scePadSetTiltCorrectionState
2026-10-02 23:02:26 +03:00
boykopovar 5026351b3f
Merge pull request #274 from RomainROCH/codex/fix-directory-buffer-errors
fix(libkernel): report undersized Windows directory buffers
2026-10-02 22:39:37 +03:00
boykopovar 55cea557ee
Merge pull request #273 from RomainROCH/codex/fix-save-memory-growth
fix(savedata): preserve memory saves when growth reads fail
2026-10-02 22:32:56 +03:00
boykopovar 11814ad660
Merge pull request #349 from DotDebian/feat/sync-on-address
feat(libkernel): implement sceKernelSyncOnAddressWait and sceKernelSyncOnAddressWake
2026-10-02 22:31:45 +03:00
boykopovar d399b4e04c
Merge pull request #245 from RomainROCH/codex/fix-windows-directory-close
fix(libkernel): clear directory metadata on close
2026-10-02 22:21:30 +03:00
boykopovar 41cb304326
Merge pull request #244 from RomainROCH/codex/fix-save-replacement
fix(savedata): preserve existing saves on replace failure
2026-10-02 22:20:58 +03:00
boykopovar 74bdce6f04
Merge pull request #232 from MichonGoddijn231849/fix/guest-read-destination
fix(libkernel): read, pread, AIO and APR write into guest memory as host writes
2026-10-02 22:19:46 +03:00
Dean Galvin b62d02c2af feat(avplayer): decode H.264 and AAC with FFmpeg
Replace the decoder-less AvPlayer with a player that demuxes MP4 sources
with FFmpeg (opened by path or through the title's file replacement),
decodes H.264 and AAC on their own threads, and hands out NV12 frames and
interleaved 16-bit PCM in buffers from the title's allocators, presented
on a media clock that audio drives when it is enabled.

Both libSceAvPlayer and libSceAvPlayer.native are built from the same
sources and link the shared ffmpeg target. The struct size checks stay,
next to the types in SceTypes.hpp. ChangeStream and GetStreamInfoEx are
implemented; Init without allocators, StartEx, SetAvailableBandwidth,
SetLogCallback and negative trick speeds succeed as before and are listed
in TechnicalDebt. HLS sources throw.

guest_avplayer plays an embedded 6 KB MP4 (H.264 plus two AAC tracks).
2026-10-03 08:10:55 +13:00
boykopovar 1cc9874ac1
Merge pull request #227 from adriadam10/feat/png-enc
feat(libScePngEnc): implement PNG encoding
2026-10-02 22:08:05 +03:00
Alberto Ruiz 95c1b40e71 fix(savedata): reject invalid directory names in sceSaveDataDelete
sceSaveDataDelete appended the title's directory name to the save root
without any check and passed the result to std::filesystem::remove_all.
"../victim" removed a directory beside the save root, ".." the directory
holding the save root, and an empty name or "." every save. The name
now has to be terminated within its field, non-empty, not "." or "..",
and free of "/", "\" and ":", as sceSaveDataMount3 already requires;
otherwise the call returns SAVE_DATA_ERROR_PARAMETER and deletes nothing.

The native library gains its own CMakeLists.txt, with the same library
definition as the generic one, to register guest_savedata_delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5WJS4ZdQynAJesCZKH5hb
2026-10-02 20:41:43 +02:00
Nicolas Abosch 35b40b76c3 feat(audio3d): implement default open parameters 2026-10-02 13:54:01 -03:00
DotDebian 1817d83fec fix(libkernel): return -1 and set errno from the POSIX open, stat, unlink and rmdir
open, _open, stat, unlink and rmdir forwarded the result of their sceKernel
twin, so a failure returned 0x8002xxxx instead of -1 and errno was never set
to the guest error. They now return -1 with errno set to the code carried by
the sce error, and report a null pointer as EFAULT and an empty path as
ENOENT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 18:17:12 +02:00
asimplestray 5d1a130902 test(shader): cover VOPC compare constants and ordered F16 2026-10-02 16:07:44 +00:00
asimplestray 20f12cc80e feat(shader): implement legacy float multiply-add ops 2026-10-02 16:04:44 +00:00
DotDebian f1be5b8ba5 fix(libkernel): report the thread's priority and affinity from scePthreadAttrGet
scePthreadAttrGet wrote priority 700 and left the affinity of the
destination untouched, whatever the thread was created with or set to
afterwards. It now reports the values the thread holds, as
pthread_attr_get_np already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 18:03:51 +02:00
asimplestray f6e689de2f feat(shader): implement MIMG sample/gather flag variants 2026-10-02 15:59:39 +00:00
DotDebian b279848c12 feat(libkernel): implement the pthread_barrierattr functions
pthread_barrier_init threw for any non-null attributes object, and no
function could create one. Add pthread_barrierattr_init, _destroy,
_getpshared and _setpshared after FreeBSD libthr, and let
pthread_barrier_init take the object.

PTHREAD_PROCESS_SHARED still throws in pthread_barrierattr_setpshared:
FreeBSD 9.0 rejects it and 11.0 accepts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 17:08:07 +02:00
Nicolas Abosch 65e59966bc feat(libSceIme): implement parameter initialization and panel size queries 2026-10-02 12:03:34 -03:00
DotDebian ba512363b1 feat(libkernel): implement sceKernelSyncOnAddressWait and sceKernelSyncOnAddressWake
sceKernelSyncOnAddressWait parks the calling thread while the 32-bit word
at the address still holds the expected value, until
sceKernelSyncOnAddressWake releases it or the timeout expires.
sceKernelSyncOnAddressWake releases up to the requested number of threads
parked on the address, in arrival order.

The libc.prx bundled with SDK 9 titles imports both for its once
primitive, so those titles stopped at load with an unresolved import.

# Conflicts:
#	docs/dev/TechnicalDebt.md
2026-10-02 16:49:44 +03:00
boykopovar a4157bbeee
Merge pull request #355 from DotDebian/feat/map-named-flexible-memory-internal
feat(libkernel): implement sceKernelMapNamedFlexibleMemoryInternal
2026-10-02 16:45:58 +03:00
boykopovar 0a2f99147f
Merge pull request #296 from Pouare514/feat/libSceJpegDec
feat(libSceJpegDec): implement JPEG decoding
2026-10-02 16:45:18 +03:00
boykopovar e00b491465
Merge pull request #286 from SP4C3B4R-8/feat/windows-mapping-hints
feat(libkernel): support mapping address hints and no-overwrite fixed mappings on Windows
2026-10-02 16:41:43 +03:00
DotDebian 74fcea27f8 feat(libkernel): implement sceKernelMapNamedFlexibleMemoryInternal
libkernel did not export sceKernelMapNamedFlexibleMemoryInternal, which
the libc bundled with SDK 9 titles imports. It now forwards to
sceKernelMapNamedFlexibleMemory: the mapping counts against the flexible
budget, gets the range name and is released by sceKernelMunmap. Older
libc builds call the public function at the same sites with the same
arguments and result handling.

The known callers pass flag 0x8000, whose meaning is unknown. It is
still rejected as an unsupported mapping flag and is recorded in
TechnicalDebt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 14:08:58 +02:00
Pouare514 c9ec561697 feat(libScePlayGoDialog): add PlayGo install dialog 2026-10-02 13:34:54 +02:00
Pouare514 8bd9670ab0 feat(libSceJpegDec): implement JPEG decoding 2026-10-02 13:34:41 +02:00
DotDebian dab1110556 feat(libkernel): implement sceKernelCancelSema
sceKernelCancelSema was a throwing stub. It now releases every thread
blocked in sceKernelWaitSema with SCE_KERNEL_ERROR_ECANCELED without
consuming tokens, sets the count to setCount (the initial count when
setCount is negative) and reports how many threads were waiting. A
setCount above the maximum returns SCE_KERNEL_ERROR_EINVAL and changes
nothing.

Waiters are counted separately from waiterCount, which is only
decremented when a waiter leaves, so two cancels in a row do not report
the same thread twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:57:00 +02:00
DotDebian d6cca762f4 feat(libkernel): support the CPU-time clocks in clock_gettime and clock_getres on Windows
CLOCK_THREAD_CPUTIME_ID (14) and CLOCK_PROCESS_CPUTIME_ID (15) threw
"unsupported clock_id" on Windows while the Linux branch already maps
them to the native clocks. clock_gettime now returns the user + kernel
time from GetThreadTimes / GetProcessTimes, and clock_getres reports the
clock interrupt period from GetSystemTimeAdjustment, which is the step
those counters actually advance by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:40:22 +02:00
DotDebian 7fd0890320 feat(libkernel): implement __elf_phdr_match_addr
Returns 1 when the address lies in an executable PT_LOAD segment of the
given dl_phdr_info, following FreeBSD lib/libc/gen/elf_utils.c (9.x and
11.x branches). The stub parameters become (dl_phdr_info*, void*) to
match the FreeBSD declaration; a null dl_phdr_info throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:18:06 +02:00
DotDebian 40d63b1b4c feat(libkernel): implement the sceKernelGetEvent* field accessors
sceKernelGetEventId, sceKernelGetEventFilter, sceKernelGetEventFflags,
sceKernelGetEventData and sceKernelGetEventUserData return the matching
field of the KernelEvent filled by sceKernelWaitEqueue and throw on a
null event. sceKernelGetEventError still throws NotImplemented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 10:46:15 +02:00
Adrià Franch 58f90eea9d feat(libScePngEnc): implement PNG encoding
scePngEncQueryMemorySize, scePngEncCreate, scePngEncEncode and
scePngEncDelete encode R8G8B8A8 and B8G8R8A8 images with a pitch into
RGB or RGBA PNGs using the shared encoder in core/Decoder/Png.
Decoder::Png::Encode takes optional compression level and filter
options so the encode parameters are honoured.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-02 10:00:32 +02:00
boykopovar a0eb90559e
Merge pull request #237 from adriadam10/fix/ajm-mp3-s16p
fix(ajm): convert planar 16-bit MP3 output from FFmpeg
2026-10-02 10:34:44 +03:00
Adrià Franch 569c2ec56c feat(libSceAudiodec): decode MP3, M4AAC and ATRAC9
All six exports are implemented: MP3 and AAC (ADTS or raw blocks) are
decoded with the bundled FFmpeg and ATRAC9 with LibAtrac9, one unit per
call, into interleaved S16 or float PCM, with the libSceAudiodec
validation and error codes. libSceAudiodec.native is built from the same
sources.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-02 09:22:59 +02:00
Adrià Franch 2036697758 fix(ajm): convert planar 16-bit MP3 output from FFmpeg
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-02 09:20:45 +02:00
Alberto Ruiz 1b2af06c92 fix(json2): reject documents nested deeper than 512 levels
The parser descends recursively into every array and object without a
limit, so deeply nested input exhausts the stack and crashes the
process: 50000 levels on an 8 MB main thread and 5000 levels (10 KB of
brackets) on a 256 KB thread. sce::Json::Parser::parse now returns
JsonErrorParse when a document opens more than 512 nested arrays or
objects, which bounds the recursion for any input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5WJS4ZdQynAJesCZKH5hb
2026-10-02 08:08:37 +02:00
RomainROCH 74586bab57 fix(libkernel): avoid semaphore count overflow 2026-10-02 06:19:39 +02:00
RomainROCH 99fbcf0377 fix(libc): propagate file position errors 2026-10-02 06:15:14 +02:00
RomainROCH 193ec6e268 fix(savedata): report memory metadata write failures 2026-10-02 06:05:54 +02:00
asimplestray f2bfdd26f9 feat(shader): implement SOP1 saveexec/wrexec family 2026-10-02 00:22:41 +00:00
SP4C3B4R-8 c4be3f78f6 feat(libScePad): implement scePadSetTiltCorrectionState
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bn7CrhG7pTPR6DT13tN6Me
2026-10-01 23:44:31 +02:00
SP4C3B4R-8 4099ffb7d3 feat(libkernel): accept MAP_NO_OVERWRITE fixed mappings on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bn7CrhG7pTPR6DT13tN6Me
2026-10-01 23:44:31 +02:00
SP4C3B4R-8 3fc3b993da feat(libkernel): honour non-fixed mapping address hints on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bn7CrhG7pTPR6DT13tN6Me
2026-10-01 23:44:30 +02:00
RomainROCH 021eb65b51 fix(libkernel): report undersized Windows directory buffers 2026-10-01 23:24:41 +02:00
RomainROCH c58f3f0a14 fix(savedata): preserve memory saves when growth reads fail 2026-10-01 23:20:39 +02:00
RomainROCH 8f76c0a57f fix(libc): release aligned allocations through the application heap 2026-10-01 22:43:44 +02:00
boykopovar 75434ee4ad
Merge pull request #240 from adriadam10/feat/pad-small
feat(libScePad): implement scePadGetHandle and the embedded mic vibration option
2026-10-01 22:00:55 +03:00
boykopovar 54c3f39680
Merge pull request #238 from adriadam10/feat/playgo-language-todo
feat(libScePlayGo): fix error codes, implement the language mask and to-do list
2026-10-01 21:58:12 +03:00
boykopovar ce6bd0c750
Merge pull request #233 from adriadam10/feat/fiber-context-size-check
feat(libSceFiber): implement context size checking and the thread frame pointer
2026-10-01 21:57:29 +03:00
boykopovar 171c9a97b2
Merge pull request #230 from asimplestray/feat/rt-miss-mode
feat(shader): add ray tracing miss fallback mode
2026-10-01 21:56:27 +03:00
boykopovar a360f162c6
Merge pull request #224 from adriadam10/feat/ces-cp1252
feat(libSceCesCs): convert single characters between CP1252 and UTF-8
2026-10-01 21:53:01 +03:00
boykopovar e0f7866205
Merge pull request #223 from adriadam10/feat/http2-ssl-stubs
feat(libSceSsl): implement CA certificate queries and sceHttp2AbortRequest
2026-10-01 21:52:19 +03:00
boykopovar 938b632784
Merge pull request #221 from adriadam10/feat/http-uri
feat(libSceHttp): implement URI parse, build and escape
2026-10-01 21:48:06 +03:00
boykopovar 01e1074efc
Merge pull request #219 from asimplestray/feat/shader-vop3-minmax16
feat(shader): implement VOP3 I16/U16 min/max/med3
2026-10-01 21:42:12 +03:00
Adrià Franch 621c8bea23 feat(libScePad): implement scePadGetHandle and the embedded mic vibration option
scePadOpen now records that the pad is open and scePadClose clears it;
scePadGetHandle returns the handle for a port scePadOpen accepts while
the pad is open, and DEVICE_NO_HANDLE otherwise. No embedded microphone
is emulated, so the option that weakens trigger vibration while it is
in use is accepted with no effect.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 19:57:32 +02:00
Adrià Franch 2b36dc2408 feat(libScePlayGo): implement the language mask and to-do list
The title is fully installed, so scePlayGoGetLanguageMask reports every
language. scePlayGoSetToDoList validates the handle, entries, chunk IDs
and loci; nothing is pending, so the list is not kept.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 19:50:33 +02:00
Adrià Franch 62530c9d5c feat(libSceFiber): implement context size checking and the thread frame pointer
sceFiberStartContextSizeCheck and sceFiberStopContextSizeCheck toggle a
mode in which new fibers get their context filled with a pattern, so
sceFiberGetInfo can report the unused stack margin.
sceFiberGetThreadFramePointerAddress returns the frame pointer of the
thread that called sceFiberRun.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 19:27:24 +02:00
asimplestray c3a740b3e6 feat(shader): add ray tracing miss fallback mode 2026-10-01 17:24:09 +00:00
Michon 676bbea348 fix(libkernel): read, pread, AIO and APR write into guest memory as host writes
A file read into guest memory is a host write: before the I/O it pins the shared pages it
covers, which reopens any page armed for write tracking and keeps write tracking from arming
it again until the read ends, when the pages count as written. A destination the guest cannot
write fails with EFAULT before any I/O; read and pread throw as for any failed read, AIO
reports SCE_KERNEL_ERROR_EFAULT, and APR throws. APR also throws when a read ends before the
requested size.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 18:56:36 +02:00
Adrià Franch fb6580ae36 feat(libSceCesCs): convert single characters between CP1252 and UTF-8
sceCesRefersUcsProfileCp1252 returns the CP1252 profile, and
sceCesSbcToUtf8 / sceCesUtf8ToSbc convert one character in each
direction. The five bytes CP1252 leaves undefined map to the matching
C1 controls, so every byte round-trips. Malformed UTF-8 and code points
outside CP1252 return the library's error codes.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 18:41:25 +02:00
Adrià Franch c548cd25b7 feat(libSceSsl): implement CA certificate queries and sceHttp2AbortRequest
sceSslGetCaCerts reports that no CA certificates are available and
sceSslFreeCaCerts clears the structure, in line with the library's
no-network behaviour. sceHttp2AbortRequest succeeds like
sceHttpAbortRequest. sceSslClose and sceSslGetSerialNumber keep throwing
and are listed as unknown signatures.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 18:35:02 +02:00
Adrià Franch 0a8cc7f543 feat(libSceHttp): implement URI parse, build and escape
sceHttpUriParse, sceHttpUriBuild and sceHttpUriEscape work on strings
only and are implemented. sceHttpCreateRequestWithURL, sceHttpReadData,
sceHttpSetChunkedTransferEnabled and sceHttpCreateEpoll follow the
existing no-network behaviour.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 18:15:50 +02:00
asimplestray b15f6800dd feat(shader): implement VOP3 I16/U16 min/max/med3 2026-10-01 16:11:33 +00:00
RomainROCH 91dd508c85 fix(libkernel): clear directory metadata on close 2026-10-01 16:48:10 +02:00
RomainROCH d7f89a6654 fix(savedata): preserve existing saves on replace failure 2026-10-01 16:40:38 +02:00
julienlgy 0c4dace39e feat(libSceHmd): add a disconnected-headset HLE stub 2026-10-01 14:18:10 +02:00
boykopovar e57ee5120d
Merge pull request #206 from Praetorian0420/main
Implement network control and socket functionality improvements
2026-10-01 11:41:41 +03:00
boykopovar 33e11c7ea2
Merge pull request #203 from oneandonlydean/fix/libkernel-direct-memory-memfd
fix(libkernel): back direct memory with a memfd on Linux
2026-10-01 11:31:43 +03:00
boykopovar e4eaba6b2e
Merge pull request #198 from MichonGoddijn231849/fix/reserve-virtual-fixed
fix(libkernel): honour MAP_FIXED in sceKernelReserveVirtualRange and sceKernelMemoryPoolReserve
2026-10-01 11:28:18 +03:00
boykopovar 89570be51b
Merge pull request #191 from asimplestray/feat/shader-vopc-cmpx
feat(shader): implement VOPC I16/U16 cmpx compares
2026-10-01 10:52:25 +03:00
Praetorian0420 e3eeac4a81 Implement network control and socket functionality improvements
- Enhanced the network control library to check for host addresses and update connection states accordingly.
- Added support for socket operations including connect, listen, accept, send, and recv in the UDP and TCP socket implementations.
- Introduced error handling for various socket operations, ensuring proper feedback for unsupported actions.
- Created comprehensive tests for both TCP and UDP socket functionalities, validating the expected behavior of the network stack.
- Refactored existing code to improve clarity and maintainability, including the removal of unused functions and the addition of necessary error checks.
2026-09-30 23:29:01 -05:00
Dean Galvin d544596283 fix(libkernel): back direct memory with a memfd on Linux
std::tmpfile() places the shared direct memory backing in /tmp, so a
title's direct memory counts against that filesystem's size (a tmpfs is
half of RAM by default): once /tmp fills, touching a backing page raises
SIGBUS. memfd_create gives the same shared memory pages without a
filesystem or its size limit.
2026-10-01 16:06:42 +13:00
asimplestray 889af1d542 feat(shader): implement VOPC I16/U16 cmpx compares 2026-09-30 23:55:29 +00:00
asimplestray 4816e105ad fix(tests): match default convention of ApplicationHeapRealign 2026-09-30 23:55:00 +00:00
asimplestray b42db4b6f3 feat(libc): implement RaiseEv, catchReturnFromMain and reallocalign 2026-09-30 23:55:00 +00:00
Michon 1d806a4688 fix(libkernel): honour MAP_FIXED in sceKernelReserveVirtualRange and sceKernelMemoryPoolReserve
Both ignored the flags and the requested address and reserved wherever the arena
had room, so a title that reserves a fixed range (Marvel's Wolverine passes
0x400010, MAP_FIXED | MAP_NO_COALESCE) and then uses the address it asked for
touched memory it never reserved. A fixed reservation now lands at the address,
after checking the range is free; other reservations are placed as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 00:00:22 +02:00
boykopovar d7ab5e371e
Merge pull request #175 from Qznad/feat/decoder-png
feat(pngdec): implement the PNG decoder
2026-09-30 21:12:56 +03:00
boykopovar 95f34bed3d
Merge pull request #171 from asimplestray/feat/kernel-time-signal
feat(kernel): implement Sleep, sigprocmask and pthread finalize
2026-09-30 21:03:48 +03:00
boykopovar c3aed31639
Merge pull request #169 from asimplestray/feat/kernel-file-ops
feat(kernel): implement file metadata ops and address conversion
2026-09-30 21:03:08 +03:00
boykopovar ba1d32f450
Merge pull request #168 from asimplestray/feat/kernel-psem
feat(kernel): implement pthread semaphore lifecycle
2026-09-30 21:01:53 +03:00
boykopovar fe712e7b9e
Merge pull request #101 from asimplestray/feat/rt-miss-config
feat(shader): configurable ray tracing miss fallback
2026-09-30 20:40:33 +03:00
boykopovar 488e678aa8
Merge pull request #161 from asimplestray/feat/libc-lifecycle
feat(libc): implement cxa lifecycle aliases and init_env
2026-09-30 20:35:36 +03:00
asimplestray 976fa82054 feat(shader): configurable ray tracing miss fallback 2026-09-30 16:53:03 +00:00
asimplestray a4e755ccb1 feat(kernel): implement file metadata ops and address conversion 2026-09-30 16:51:37 +00:00
boykopovar f881e021a8
Merge pull request #160 from asimplestray/feat/libc-wide-io
feat(libc): implement fputwc, fputws and fscanf
2026-09-30 19:40:31 +03:00
Dean Galvin 48687eefab fix(contentexport): refuse init parameters without allocators or with reserved fields set
sceContentExportInit2 accepted any non-null parameter block. It now throws
when the malloc or free function is missing or a reserved field is not
zero. A test covers these refusals and the init and term order.
2026-09-30 18:35:36 +03:00
boykopovar 119a74952a
Merge pull request #126 from oneandonlydean/feat/systemservice-hdr-tone-map
feat(systemservice): report the SDR tone-map luminance
2026-09-30 18:12:00 +03:00
boykopovar 077d4a487f
Merge pull request #125 from oneandonlydean/feat/pthread-prio-inherit
feat(libkernel): accept priority-inheritance mutexes
2026-09-30 18:11:38 +03:00
boykopovar f952bbeeb7
Merge pull request #121 from oneandonlydean/feat/linux-guest-write-watch
feat(agc): track guest memory writes on Linux with async userfaultfd write protection
2026-09-30 18:10:48 +03:00
boykopovar 1e1f0562c6 refactor(videodec2): use shared ffmpeg-core submodule + remove black fallbacks 2026-09-30 17:41:49 +03:00
Pacuka a38ef6132f feat(videodec2): decode H.264 with FFmpeg
Adds libSceVideodec2. Access units (Annex B, or length-prefixed rewritten to
Annex B) are decoded by FFmpeg's H.264 decoder into the title's NV12 frame
buffers (256-byte pitch, chroma after the visible luma rows). Decode hands
out at most one picture per call, Flush drains the reordered ones, Reset
clears the decoder; timestamps and attached data travel with the picture.
FFmpeg is found through pkg-config and is optional: without it the decoders
return black pictures. guest_videodec2_tests checks the pictures of an
embedded stream against reference hashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 17:30:58 +03:00
Dean Galvin d8c7c0ccdf feat(agc): track guest memory writes on Linux with async userfaultfd write protection
GuestMemory::CollectWrites was built on the Windows arena's MEM_WRITE_WATCH
and answered 0 on Linux, so every cached copy of guest memory (textures,
resident render targets, buffers, DCC key proofs) read as changed at every
check: resident targets were stored and re-uploaded at every refresh and
unit shadows stayed off. Astro Bot's intro ran at ~3 fps.

libc gains GuestWriteWatch, the Linux counterpart of GetWriteWatch. Every
guest mapping libkernel makes (MapAligned: fixed, hinted and aligned) is
registered with one userfaultfd in asynchronous write-protect mode
(UFFD_FEATURE_WP_ASYNC: the kernel lifts a page's protection on its first
write without a handler thread, for user and kernel-mode writes alike), and
PAGEMAP_SCAN with PM_SCAN_WP_MATCHING reports the pages written since the
last scan of a range and protects them again in one call. Unmap forgets
the range. Direct memory is mapped from shared backings over its
reservation and a fixed remap replaces the mapping, so both register the
new mapping afresh. The watch is per mapping: a write through one mapping
of shared physical pages is not seen at another, so physical pages mapped
at more than one address leave the watch in every mapping of them.

A registered mapping reads as written until a collect covers it. The watch
keeps that itself instead of relying on how the kernel classifies pages
never faulted in: Linux 6.17 reports a range without page tables as not
written and leaves it unprotected, 7.2 reports it as written. The first
collect of a fresh range reports it written and write-protects it with
UFFDIO_WRITEPROTECT, which puts markers on its unpopulated pages
(UFFD_FEATURE_WP_UNPOPULATED), so from then on only real writes report.

Fallback: the userfaultfd is opened with UFFD_USER_MODE_ONLY where
vm.unprivileged_userfaultfd restricts it, and a probe at startup checks the
mechanism on scratch pages (a populated and an unpopulated page written
after protection report exactly, untouched ones do not). Without it (kernel
older than 6.7, no userfaultfd permission, headers without PAGEMAP_SCAN, or
APS5_NO_WRITE_WATCH=1) the watch reports unavailable and the tracker stays
unwatched exactly as before: CollectWrites answers 0 and callers compare
bytes. A range with a page outside the registered mappings also answers 0,
and a protection or scan that fails reports its remaining pages as written
and answers 0.

The driver's tracker keeps its contract and generations. On Linux its
block stamps live in 4 GiB leaves over the user address space, made on
first stamp, instead of the arena's flat arrays; the collect memo now works
on both platforms. GuestMemory::WriteWatched and Watched replace the arena
queries in UnitShadowEnabled and ShadowDestinationFor, so unit shadows run
on Linux over watched memory and stay off everywhere else. The Windows
arena path is unchanged apart from going through the same stamp helpers.

Host imports: a driver may lift the write protection of imported pages
itself. amdgpu validates the userptr BO behind a VK_EXT_external_memory_host
import with a writable HMM fault on every submission after the pages were
protected again, so PAGEMAP_SCAN reports them as written with no CPU store,
and a resident display image read as written at every present (found by
Pacuka on an RX 6650 XT with RADV: the presented image went black). NVIDIA
pins the pages once at the import and stays exact from then on. A probe at
device setup decides per device: it maps and watches scratch pages, collects
them clean, imports them, collects, submits a GPU copy that reads the import,
waits, and collects again. Pages written after the submission mean imports
resolve write protection: every import from then on takes its range off the
watch (GuestMemory::Unwatch) before it is made, so Watched is false for it,
CollectWrites answers 0 and callers compare bytes; GPU writes to watched
memory keep their MarkWritten stamps. The result is logged once:
"[write-watch] host imports resolve write protection: yes/no". A probe that
cannot run takes the unwatch side. APS5_WRITE_WATCH_IMPORTS=watch|unwatch
overrides the probe (default probe; anything else throws), and
APS5_NO_WRITE_WATCH=1 still turns the watch off. On the RTX 4090 the probe
reads 0 of 4 pages written after the GPU read (4 after the import itself),
so imports stay watched there.

The import itself lifts the protection once where imports stay watched:
on the RTX 4090 the pinning at vkAllocateMemory reports every imported page
as written (4 of 4 in the probe), with no CPU store. Such a report would
read as a CPU write over any GPU results pending in the range and drop
them. So every import of a watched range is made inside an import window
(GuestMemory::ImportWatched), under the tracker lock: the range is
collected right before the import, so earlier CPU writes are stamped as
usual, and again right after it, and what the window reports is stamped
"maybe written". Readers without pending results see it as a change
(UnchangedSince fails, ChangedBlocks reports it), so caches re-upload or
compare. Decisions about pending GPU results read it as untracked:
ChangedBlocks reports BlockMaybeWritten apart from BlockWritten, and the
drop rule, the write-back's keep blocks, the alias checks, the unit
shadow's stale drop and the whole-image stale checks (through the new
WrittenSince, which also answers false for a range off the watch) store
the results instead of dropping them. A real CPU store racing an import
also races the pending GPU writes to the same memory, which has no
defined order on hardware either, so the GPU results winning is
acceptable. From the second collect on the range is protected again and
watched normally. A range the watch does not cover whole, or a collect of
the window that fails, is taken off the watch instead.

An unwatched import stays off the watch for the rest of its mapping: a
remap registers the range afresh, the import kept over it takes it off
again at the next reconcile, and a re-import after an unmap follows the
decision. Unwatch invalidates the collect memo, so a collect memoized
before the import answers 0. A range that leaves the watch while a storage
image holds a generation for it no longer reads as CPU-written:
ChangedBlocks now tells whether the range is watched, and the drop rule,
the write-back's keep blocks and the alias borrow treat an unwatched range
as untracked (stored, never dropped), as a generation of 0 is.

Tests: guest_memory checks the watch through libkernel mappings (a CPU
store, a read, a kernel write through read(), another thread, a memcpy
across pages, an mprotect cycle, a partial munmap and a fixed remap) and
over a fresh 2 MiB-aligned mapping without page tables, checks direct
memory (watched, an alias takes the shared pages off the watch in both
mappings, a fixed direct remap over flexible memory is watched afresh), and
names the failing line and the reported pages. The recorder tests allocate watched
memory on both platforms, so the UnchangedSince, key proof, close race and
unit shadow tests run on Linux, and the storage refresh test gains a
watched variant: results kept on the GPU reach a CPU reader, and a plain
CPU store into one unit with newer results pending is found by the watch
alone. The recorder tests now also run the real import probe, check the
decision with the result injected (unwatch: an import leaves the watch, a
memoized collect, a partly imported range and the unimported neighbour
answer as they should, MarkWritten stamps only watched memory, a remap and
a re-import after an unmap follow the decision; watch: the import stays
watched and stamped), and check that results pending when their memory
leaves the watch are stored rather than dropped. A further test imports the
memory of a storage image with results pending in watch mode: the
results survive the import window and reach guest memory, a cache
generation taken before the import sees a change, the window reads as
maybe written and not as a CPU store, and a CPU store after it reads as
one again. Unit shadows and the
watched storage refresh report themselves as not run when imports are
compared.
2026-10-01 00:08:08 +13:00
Qznad a0e2f88048 feat(pngdec): implement libScePngDec on the shared PNG decoder 2026-09-30 11:10:00 +01:00
boykopovar 5e08eb4cce perf(memory): skip redundant page scans in shared write tracking 2026-09-30 09:59:51 +03:00
boykopovar abb9c85266 fix(kernel): share direct memory mappings and track physical offsets 2026-09-30 09:59:51 +03:00
asimplestray c6d098d487 feat(kernel): implement Sleep, sigprocmask and pthread finalize 2026-09-29 23:40:48 +00:00
asimplestray 064006b617 feat(kernel): implement pthread semaphore lifecycle 2026-09-29 22:13:07 +00:00
asimplestray 40eeb4be40 fix(libc): use guest calling convention for atexit callbacks 2026-09-29 21:33:44 +00:00
asimplestray 85a0ec2e69 fix(libc): convert sysv va_list for fscanf on Windows 2026-09-29 21:32:30 +00:00
asimplestray 3bf115585c feat(libc): implement cxa lifecycle aliases and init_env 2026-09-29 21:29:13 +00:00
asimplestray 77194e4561 feat(libc): implement fputwc, fputws and fscanf 2026-09-29 21:25:07 +00:00
STL1te 03465e769c test(kernel): a second view of direct memory shares the page
Since direct memory mapped at two addresses is shared read-only instead of
refused, the guest memory test expected an exception that no longer comes.
It now maps the second view, reads the first view's bytes through it, and
writes through the first view once the second is gone, which faults unless
its protection came back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:28:49 +03:00
STL1te 6b36c050fe style: drop the branch's code comments per CONVENTIONS.md
Only the lines this branch added lose their comments; the commits before
keep them, with the reasoning behind each change, for whoever digs into
that code later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:25:29 +03:00
STL1te c206f7049a feat(kernel, libc): memory, files and threads for retail title boot
libkernel:
- direct memory keeps its contents per physical page across unmap and
  remap; a page mapped at two live addresses at once throws
- sceKernelDirectMemoryQuery answers from tracked allocations
- SCE protections read back as set, GPU and AMPR bits included
- APR prefix path resolve, file size and stat by id, positional reads,
  fsync/pread/pwrite; directories open as descriptors on Windows
- sceKernelCheckReachability, getpeername, shutdown
- Dinkumware C11 threads (_Mtx_*, _Cnd_*, _Thrd_*) in the title libc
  layout; any pthread stack size, rounded at thread creation

libc:
- unaddressed guest mappings go to the system-managed area from
  0x2_0000_0000, leaving the application area to fixed mappings
- the process starts in /app0
- guest sscanf on Windows; a null %s prints as (null) as on FreeBSD
- localeconv, _FNan, _FDtest, _FExp, __udivti3, wcsncpy_s, aligned
  operator new, _Throw_Cpp_error

Tests: direct memory following physical pages, guest formatting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:22:13 +03:00
boykopovar 75a8668b5e
Merge pull request #116 from oneandonlydean/fix/json2-reference-getters
fix(json2): referValue returns null for a missing member, getters return references
2026-09-29 20:51:57 +03:00
Julien Legay bd3e41b28f Implement player invitation dialog HLE stub 2026-09-29 19:07:03 +03:00
Qznad aad41aa907 feat(jpegenc): encode images through the shared JPEG encoder 2026-09-29 15:17:27 +01:00
Qznad aa56049fbf feat(jpegenc): validate sceJpegEncEncode arguments 2026-09-29 15:17:27 +01:00
Qznad 98a5228cf7 feat(jpegenc): implement sceJpegEncCreate and sceJpegEncDelete 2026-09-29 15:17:27 +01:00
Qznad 16290424b9 feat(jpegenc): implement sceJpegEncQueryMemorySize 2026-09-29 15:17:27 +01:00
boykopovar c0755b9ec8
Merge pull request #102 from asimplestray/feat/kernel-aio
feat(kernel): implement Aio request lifecycle
2026-09-29 11:07:10 +03:00
Dean Galvin 6c98b6be58 feat(systemservice): report the SDR tone-map luminance
sceSystemServiceGetHdrToneMapLuminance was NotImplemented. Titles read
it at startup to set up their HDR tone mapping.

The presenter always outputs through a B8G8R8A8 sRGB-nonlinear swapchain,
so the display range the title has to map into is SDR: the maximum and
full-frame maximum luminance are the 100 cd/m2 SDR reference white and
the minimum is 0. A null output pointer returns
SYSTEM_SERVICE_ERROR_PARAMETER like the other getters here.
2026-09-29 13:56:45 +13:00
Dean Galvin 70bbd700e2 feat(libkernel): accept priority-inheritance mutexes
scePthreadMutexattrSetprotocol threw for SCE_PTHREAD_PRIO_INHERIT, so a
title creating its mutexes with priority inheritance stopped at the
first one.

Guest thread priorities are recorded (scePthreadSetprio/Getprio) but
never applied to host scheduling, so there is no priority for a waiter
to lend to the owner: an inheriting mutex locks, unlocks and reports
errors exactly like a PRIO_NONE one here, and the protocol is accepted.
The POSIX pthread_mutexattr_setprotocol wrapper already accepts it.
Priority protection (PRIO_PROTECT, with its ceilings) and unknown
protocols still throw.
2026-09-29 13:22:21 +13:00
Dean Galvin 90855bbc18 fix(json2): referValue returns null for a missing member, getters return references
sce::Json::Value::getBoolean, getInteger, getUInteger and getReal return const references
(const bool&, const long&, const unsigned long&, const double&), so the guest reads the value
through the returned pointer. A value-returning implementation made callers dereference the value
itself. Cross-type conversions keep main's range rules and are stored on the node so the reference
stays valid.

Value::referValue(const String&) looks a member up without creating it: it returns null for a
missing key or a value that is not an object instead of inserting an entry or throwing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-29 13:02:54 +13:00
Dean Galvin 8f982168e2 perf(libc): replace the mspace block list with an ordered allocator
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-29 12:53:00 +13:00
boykopovar 9e3df3331c
Merge pull request #107 from asimplestray/feat/libc-mspace-reallocalign
feat(libc): implement sceLibcMspaceReallocalign
2026-09-29 01:46:19 +03:00
asimplestray 02b431eb6d feat(libc): implement sceLibcMspaceReallocalign 2026-09-28 22:15:25 +00:00
boykopovar 4c2b052e35
Merge pull request #58 from oneandonlydean/feat/font-freetype
feat(font): port shadPS4's sceFont and sceFontFt on FreeType
2026-09-29 01:07:30 +03:00
asimplestray c25c543f1c feat(kernel): implement Aio request lifecycle 2026-09-28 20:39:33 +00:00
SamG-Coder 8cef034172 fix(shader): safely destroy compiler thread-local storage on Windows 2026-09-28 19:54:01 +10:00
boykopovar 8bd030d531
Merge pull request #26 from QDarkRex/fix/kernel-error-codes
fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex
| Constant | Before | After |
|---|---|---|
| `EQUEUE_ERROR_ETIMEDOUT` | `0x80010023` | `0x8002003C` |
| `EQUEUE_ERROR_EBADF` | `0x80010016` | `0x80020009` |
| `EQUEUE_ERROR_ENOENT` | `0x80010011` | `0x80020002` |
| `EQUEUE_ERROR_EINVAL` / `SCE_KERNEL_ERROR_EINVAL` (DirectMemory) | `0x80010005` | `0x80020016` |
| `EQUEUE_ERROR_EFAULT` / `SCE_KERNEL_ERROR_EFAULT` (DirectMemory) | `0x80010009` | `0x8002000E` |
| `SCE_KERNEL_ERROR_EAGAIN` (DirectMemory) | `0x80010002` | `0x80020023` |
| `SCE_KERNEL_ERROR_ENOMEM` (DirectMemory) | `0x80010007` | `0x8002000C` |
| `SCE_KERNEL_ERROR_EACCES` (DirectMemory) | `0x80010004` | `0x8002000D` |
| `SCE_KERNEL_ERROR_EDEADLK` (Mutex.cpp) | `0x80020023` (= EAGAIN) | `0x8002000B` |
2026-09-28 11:18:14 +03:00
Claude a28cfb7585
Merge upstream main into fix/kernel-error-codes
Resolve the conflict with boykopovar/AnyPS5#10 in Pthread/src/Mutex.cpp
by taking upstream: its rewrite already returns EDEADLK as 0x8002000B.
The equeue and direct memory error code fixes are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:36:16 +00:00
Claude 210987745c
Merge upstream main into fix/audit-2026-09
Resolve conflicts with boykopovar/AnyPS5#10 (sce module loading) and
later upstream changes.

- Pthread Cond/Mutex: take upstream. It already releases mutex
  ownership across condition waits, returns ETIMEDOUT 0x8002003C, and
  rejects unlocks from non-owners for every mutex type.
- Pthread Thread: keep upstream's lifecycle, Windows adoption and job
  affinity; re-apply the POSIX fixes on top: reference-counted
  release on join/detach/exit, self-join rejection on both platforms,
  and scePthreadSelf adoption for threads not created by
  scePthreadCreate.
- Semaphore: keep upstream's TimedWait::Condition and wait tracing;
  re-apply sceKernelDeleteSema waking waiters with EACCES.
- Relinker: keep --windows-gui alongside upstream's --skip-sce-module,
  trampoline-aware Patch signature and new Python tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:34:25 +00:00
boykopovar 34f0379d8a
Merge pull request #48 from oneandonlydean/feat/linux-fibers
feat(fiber): implement fibers on linux
The state machine, the cross-thread resume handling and the entry trampoline are now shared between platforms. Only the context switch differs:
- `Aps5FiberSwitchStack` saves the SysV callee-saved set (`rbp rbx r12–r15`, MXCSR and the x87 control word) instead of the Win64 set.
- `Aps5FiberTrampoline` passes the fiber in `rdi`.
- There is no TIB to update, so `CurrentBounds`/`SetBounds` do nothing on Linux.
2026-09-28 10:22:04 +03:00
boykopovar 3b4e4f6de6
Merge pull request #65 from SamG-Coder/main
fix(agc): keep BGRA color targets resident between draws
BGRA color targets fail the exact guest-texture-format lookup and fall back to a synchronous framebuffer round-trip for every draw. This keeps them resident using compatible RGBA storage with the original BGRA attachment view. Presentation checks the actual display channel order, attachment views request only attachment usage, and host-write barriers include the host stage.

This follows the existing linked PRX/Vulkan path. It adds no interpreter, separate runtime process, or new shader compilation path.
2026-09-28 10:07:16 +03:00
Dean Galvin ba9201874f feat(fiber): implement fibers on linux
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 19:46:38 +13:00
boykopovar d942a604a9
Merge branch 'main' into feat/font-freetype 2026-09-28 09:44:53 +03:00
boykopovar b985d17f82
Merge pull request #57 from oneandonlydean/feat/json2
feat(json2): implement sce::Json values, strings, arrays, objects, parser and null-access callback
- **Layouts:** `String`, `Array`, `Object` and `Value` are pointer-sized handles to host-side storage. The title stores `String`/`Array`/`Object` at an 8-byte stride and `Value` in 0x20-byte slots, so none of them can be bigger. The pair an `Object::iterator` dereferences to has its key at +0x00 and its `Value` at +0x10, which the title reads directly. Array and object iterators are 8 bytes.
- **Parser:** a strict RFC 8259 parser.
  - Numbers: integers that fit `int64` become `Integer`, larger non-negative ones `UInteger`, and everything else `Real`.
  - Strings: `\u` escapes, including surrogate pairs, are decoded to UTF-8.
  - Errors: on any error `parse` returns a negative code (`0x80920101`) and leaves the target value untouched.
- **Serialisation:** compact output. Strings are escaped; reals use `%.17g`, and a non-finite real throws.
- **Null access:** a typed getter on a value of another type, a missing key or an out-of-range index goes through the null-access callback. The callback's result is used when its type matches (any type for `operator[]`). Otherwise a static default value of the requested type is returned. `terminate` clears the callback.
- **Integer getters:** `getInteger`/`getUInteger`/`getReal` convert between the integer kinds and to real where the value fits.
- `setGlobalNullAccessCallBack` (NID `00oCq0RwSAY`) was identified by hashing its mangled name.
- `MemAllocator`'s base constructor and destructor install the abstract class's vtable. A derived allocator replaces it with its own, so its entries (which throw, like a pure virtual call) run only if a pure virtual is called. `Initializer::initialize` throws on a null parameter instead of silently accepting it.
- Mutating a value that isn't the expected type (`referArray` on a string, etc.) throws.
2026-09-28 09:42:21 +03:00
boykopovar 73d014ed83
Merge pull request #56 from oneandonlydean/feat/linux-pread-getdents
feat(libkernel): pread, pwrite, getdents and getdirentries on linux
- **pread/pwrite:** use the existing `NativePread`/`NativePwrite` and don't move the file offset. A null buffer with a non-zero size returns `EFAULT`, a negative offset `EINVAL`, and host failures go through `SceErrorFromErrno`.
- **getdirentries:**
  - reads host `getdents64` records and converts them to the FreeBSD `struct dirent` layout the guest expects (`d_fileno` u32, `d_reclen` u16, `d_type` u8, `d_namlen` u8, NUL-terminated name, record padded to 4 bytes);
  - `*basep` gets the directory position from before the read;
  - when a record doesn't fit in the guest buffer, the descriptor is moved with `lseek` back to that entry's cookie, so the next call resumes there;
  - if not even the first record fits, the call returns `EINVAL` without consuming anything, and a name longer than 255 bytes returns `ENAMETOOLONG`.
- **getdents** is `getdirentries` without `basep`.
- Adds the guest `EFAULT`, `EINVAL` and `ENAMETOOLONG` constants.
2026-09-28 09:38:47 +03:00
SamG-Coder fa787cfbe9 fix(agc): keep BGRA color targets resident between draws 2026-09-28 16:26:02 +10:00
boykopovar 244b915c75
Merge branch 'main' into feat/libc-runtime-functions 2026-09-28 09:01:41 +03:00
boykopovar ce6ac25b7e
Merge pull request #49 from oneandonlydean/feat/mspace-extensions
feat(libc): mspace memalign, malloc stats, thread-unsafe flag and nested mspaces
- Memalign uses the existing aligned allocation.
- Stats fill `SceLibcMallocManagedSize` (size checked against 0x28) from new `inUse`/`peakInUse` counters on the arena. The system size is the arena's extent.
- The thread-unsafe flag is accepted: the implementation always locks, so skipping locks is only an optimisation it doesn't need. Other flags are still rejected.
- An overlapping create is allowed only when the new range lies entirely inside a live block of the other mspace. Every other overlap is still rejected.
2026-09-28 08:58:28 +03:00
boykopovar d653d85538
Merge pull request #50 from oneandonlydean/feat/libkernel-mappings
feat(libkernel): hinted and no-overwrite mappings, virtual range names and usleep
- **Non-fixed mapping with an address hint:** `MapAligned` threw `Non-fixed mapping address hints are not implemented`. On the PS5 the hint is where the search starts. On Linux the mapping is now placed at the first free, aligned range at or above the hint, found from `/proc/self/maps` and mapped with `MAP_FIXED_NOREPLACE` so nothing existing can be replaced. `RequireAvailable` is now only checked for fixed mappings, because a hint may point at used memory. Windows still throws.
- **`SCE_KERNEL_MAP_NO_OVERWRITE` (`0x80`):** it was rejected as an unknown flag. With `MAP_FIXED` on Linux it maps with `MAP_FIXED_NOREPLACE`, and it no longer takes the "remap fixed into registered" path, so it fails instead of replacing a registered range. The unsupported-flags error now includes the flag value.
- **Virtual range names:** `sceKernelSetVirtualRangeName` was `NotImplemented` and `sceKernelClearVirtualRangeName` wasn't exported. Names are now kept in a registry, split and trimmed on overlap. `sceKernelVirtualQuery` reports the name and splits its reported region at name boundaries. `sceKernelMapNamedDirectMemory` and `sceKernelMapNamedFlexibleMemory` now name the range instead of ignoring the name.
- **`usleep`** is exported (POSIX, beside `nanosleep`).
2026-09-28 08:54:42 +03:00
boykopovar a8d6f8664e
Merge pull request #63 from oneandonlydean/feat/libc-sscanf-s
feat(libc): sscanf_s on linux
sscanf_s was a NotImplemented placeholder in libc/Export.cpp, and a retail title uses it to parse strings. It's now implemented on Linux. Windows still throws NotImplemented.
2026-09-28 08:18:32 +03:00
Dean Galvin 20cc23438f feat(libc): sscanf_s on linux
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:53:29 +13:00
Dean Galvin 00e4f7678d feat(font): port shadPS4's sceFont and sceFontFt on FreeType
Ported from shadPS4 (GPL-2.0-or-later) with system fonts removed, stubs made to throw,
and sceFontCloseFont implemented.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:45:30 +13:00
Dean Galvin 390e4cd800 feat(json2): implement sce::Json values, strings, arrays, objects, parser and null-access callback
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:42:29 +13:00
Dean Galvin f7e1bdf0b9 feat(libkernel): pread, pwrite, getdents and getdirentries on linux
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:40:22 +13:00
Dean Galvin a599eca727 feat(libc): operator new/delete, bounds-checked functions, char locale facets and runtime helpers
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean Galvin 3058980d96 feat(libc): mspace memalign, malloc stats, thread-unsafe flag and nested mspaces
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean Galvin 9754937a5d feat(libkernel): hinted and no-overwrite mappings, virtual range names and usleep
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
SamG-Coder e424b6b7bf fix(agc): preserve recorder buffers through Windows thread teardown 2026-09-28 09:55:01 +10:00
SamG-Coder 9814c93f75 fix(agc): avoid exception-driven render target format probing 2026-09-28 09:55:00 +10:00
SamG-Coder fc26cff30f test(shader): cover decoded buffer address operands 2026-09-28 09:09:02 +10:00
SamG-Coder b25025c682 fix(agc): support explicit indexed draw commands 2026-09-28 09:09:02 +10:00
SamG-Coder 07930c6726 feat(videoout): present linear framebuffer layouts 2026-09-28 09:05:49 +10:00
SamG-Coder 67fce999c5 fix(libc): support SDK startup without allocator replacements 2026-09-28 09:03:10 +10:00
devilismyfriend a503d0b617 Merge remote-tracking branch 'origin/main' into feat/demons-souls-boot
Brings in main up to 9958d26 (homebrew runtime, POSIX wrappers in
libkernel, sce_module guest modules and --skip-sce-module, the --to-intel
general pipeline, libSceRandom, libSceRtc, libScePosixForWebKit,
libRenoirCore, test wiring).

Resolutions where both sides implemented the same thing:
- libkernel pthread: main's structure (lazy static initialisation,
  destroyed markers, MutexOperations/CondOperations, mutex protocol and
  condattr clock) with this branch's TimedWait deadlines and condition
  (precise timed lock/wait on Windows), wait tracing, the adaptive mutex
  type 4, POSIX default ERRORCHECK mutexes, EDEADLK/EPERM results instead
  of throws, and condition clocks honoured for absolute timeouts.
- libc locale: the guest Dinkumware ABI (_Locimp, facet vtables, short
  ctype/case tables, locale ids, stream storage) is kept because guest code
  inlines those layouts; main's C character functions are kept on top.
- libc stdio/strings/math: main's stream functions (guest FILE status
  sync), strerror/perror, remove, formatting, string and math exports win
  over this branch's duplicates.
- libc paths: main's working directory with this branch's path aliases
  resolved on the normalised guest path.
- libkernel file: this branch's sceKernel* results as SCE errors, main's
  POSIX wrappers and both fstat helpers.
- relinker: this branch's stub lowering keeps its trampolines through the
  main executable path; guest modules refuse lowerings that need stubs.
- AGC driver: main's rendering wait is executed by this branch's workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 10:52:21 -07:00
boykopovar e526f1f528 feat(libc): replace guest locale implementation with std::locale 2026-09-27 11:43:42 +03:00
QDarkRex 97cae1458e fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex
SCE kernel errors are 0x80020000 plus the FreeBSD errno. The equeue and
direct memory constants used an unrelated 0x8001xxxx range with mismatched
errno values (e.g. ETIMEDOUT was 0x80010023), so a guest checking
sceKernelWaitEqueue for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error.
SCE_KERNEL_ERROR_EDEADLK in Mutex.cpp held the EAGAIN value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:22:01 +07:00
QDarkRex 76b7f998f5 fix(kernel): give every thread a pthread handle and keep mutex ownership consistent
- scePthreadSelf returned null on Linux and for threads not created by
  scePthreadCreate (including the main thread); such threads now get a
  lazily adopted, non-joinable handle
- scePthreadExit on Linux skipped FinishThread, losing the join value
- detached threads on Linux were never freed; use the reference count
  already used on Windows
- unlocking a recursive mutex from a non-owner was undefined behaviour;
  return SCE_KERNEL_ERROR_EPERM
- scePthreadCondTimedwait did not restore the mutex owner after waking,
  so another thread locking during the wait made the waiter's unlock
  fail with EPERM and left the mutex locked forever
- SCE_KERNEL_ERROR_ETIMEDOUT in Cond.cpp was 0x80020062 instead of 0x8002003C

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:38:59 +07:00
devilismyfriend af3c2024ed feat(runtime): timed waits, sync primitive fixes, heap and RTC fixes, unattended-run switches
libkernel: a TimedWait service for condition variables, semaphores, event flags, rwlocks and
equeues with the scheduler tick; mutex/cond/sem corner cases the title hits; job worker
affinity is opt-in (APS5_JOB_AFFINITY). libc: calloc/realloc heap slot swap, a default
terminate handler with a backtrace, CPU topology helper. libSceRtc export fixes with tests.
libSceVideoOut: APS5_NO_PAD_INPUT ignores host input for unattended measurements,
APS5_FLIP_QUEUE_WAIT keeps a stalled process alive for a debugger. ApplicationHeap and
GuestRtc tests wired into the test build.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-26 19:00:39 -07:00
boykopovar 1a0ebbc849
Merge pull request #9 from Pacuka/feat/scertc
feat(rtc): implement libSceRtc date and tick functions
- Ticks count microseconds since 0001-01-01 00:00:00 in the proleptic Gregorian calendar, up to 9999-12-31 23:59:59.999999. `sceRtcGetTickResolution` returns 1000000.
- Validation (`sceRtcCheckValid`, `sceRtcIsLeapYear`, `sceRtcGetDayOfWeek`) returns the matching `SCE_RTC_ERROR_INVALID_*` code (`0x80B50002`–`0x80B5000E`).
- Conversions: `sceRtcGetTick`/`SetTick`, `GetTime_t`/`SetTime_t`, `GetWin32FileTime`/`SetWin32FileTime`.
- Current time: `sceRtcGetCurrentTick`, `GetCurrentClock`, `GetCurrentClockLocalTime`. `sceRtcGetCurrentNetworkTick` uses the host clock.
- UTC and local time conversion through the host time zone.
- `sceRtcFormatRFC3339` (`YYYY-MM-DDThh:mm:ss.cc` plus `Z` or `±hh:mm`) and `sceRtcParseRFC3339`.
- Tick arithmetic (`sceRtcTickAdd*`) rejects results outside the valid range with `SCE_RTC_ERROR_INVALID_VALUE`.
- New exports: `sceRtcGetDaysInMonth`, `sceRtcTickAddMonths` and `sceRtcTickAddYears`. The last two clamp the day to the end of the target month (2024-01-31 + 1 month = 2024-02-29).
2026-09-26 13:41:16 +03:00
Pacuka c0508a7f5f feat(rtc): implement libSceRtc date and tick functions
Ticks count microseconds since 0001-01-01 in the proleptic Gregorian
calendar, up to 9999-12-31 23:59:59.999999. Implement validation, tick
and date conversion, time_t and Win32 FILETIME conversion, UTC and
local time conversion through the host time zone, RFC 3339 formatting
and parsing, and tick arithmetic. Add sceRtcGetDaysInMonth,
sceRtcTickAddMonths and sceRtcTickAddYears, which clamp the day to the
end of the target month.

The network clock uses the host clock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 12:21:23 +02:00
Pacuka d1c25097e3 feat(random): implement sceRandomGetRandomNumber
Fill the buffer from std::random_device and reject a null buffer or a
size above SCE_RANDOM_MAX_SIZE (64) with SCE_RANDOM_ERROR_INVALID, as
the system library does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 12:14:46 +02:00
Pacuka 998605fe4e fix(libc): swap calloc and realloc slots of the malloc replacement table
SceLibcMallocReplace lists calloc before realloc (malloc, free, calloc,
realloc, memalign, reallocalign, posix_memalign, ...), as the table in
retail titles shows. realloc therefore called the application's calloc
with the old pointer as the element count, and calloc called realloc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
SamG-Coder f37fffdacd feat(libc): expose guest vsprintf formatting 2026-09-25 07:26:06 +10:00
SamG-Coder 6cdf4a5be1 feat(libc): implement binary search with guest comparator ABI 2026-09-25 07:24:17 +10:00
SamG-Coder 473a4f8d1c fix(agc): preserve strict shader linkage failures 2026-09-25 07:22:06 +10:00
SamG-Coder 322dc24c9e feat(kernel): implement guest once initialization 2026-09-25 07:22:05 +10:00
SamG-Coder 95dc22c173 feat(agc): execute rendering waits against buffer reuse fences 2026-09-25 07:16:55 +10:00
SamG-Coder cca00c13ab feat(video): track ordered buffer reuse reservations 2026-09-25 07:13:15 +10:00
SamG-Coder 2187436d0d feat(agc): expose legacy register defaults entry point 2026-09-25 07:10:15 +10:00
SamG-Coder d6f23df679 feat(agc): compose basic shader linkage register blocks 2026-09-25 07:08:10 +10:00
SamG-Coder 18ce03cba2 feat(libc): implement immediate guest process exit 2026-09-25 07:05:07 +10:00
SamG-Coder dd0debe967 feat(libc): reopen guest streams while preserving identity 2026-09-25 07:05:07 +10:00
SamG-Coder 2920c7f04c feat(system): handle console exit through runtime shutdown 2026-09-25 07:02:37 +10:00
SamG-Coder 79edb20f17 fix(libc): preserve 64-bit guest stream offsets 2026-09-25 07:00:45 +10:00
SamG-Coder 39b81364b7 feat(libc): add C-locale character APIs and guest basename 2026-09-25 06:58:41 +10:00
SamG-Coder 7d07187ac8 feat(libc): add floating-point string conversions 2026-09-25 06:55:31 +10:00
SamG-Coder c7d26dda5e feat(libc): add missing guest math exports and 64-bit rounding 2026-09-25 06:54:49 +10:00
SamG-Coder 730afc79f8 feat(libc): add independent guest strtok state 2026-09-25 06:52:05 +10:00
SamG-Coder 1b45b0fe68 feat(libc): track guest working directory and resolve relative paths 2026-09-25 06:51:37 +10:00
SamG-Coder 453fec28c5 feat(kernel): add tracked dynamic module loading and NID lookup 2026-09-25 06:48:50 +10:00
SamG-Coder 91bf8e3a7a feat(libc): implement guest file removal and renaming 2026-09-25 06:45:30 +10:00
SamG-Coder 5301f89092 feat(libc): translate guest directory enumeration 2026-09-25 06:41:55 +10:00
SamG-Coder 18790691bd feat(libc): implement guest environment variable storage 2026-09-25 06:39:14 +10:00
SamG-Coder f49cace1ca feat(libc): implement guest formatted stream output 2026-09-25 06:35:32 +10:00
SamG-Coder b8c1097db4 feat(kernel): support socket nonblocking flags through fcntl 2026-09-25 06:34:30 +10:00
SamG-Coder e8ecb29170 feat(libc): expose guest standard streams and character IO 2026-09-25 06:30:30 +10:00
SamG-Coder 56c7a589db feat(kernel): bridge guest signal registration and delivery 2026-09-25 06:27:11 +10:00
SamG-Coder cbd22dd854 feat(kernel): implement guest system configuration queries 2026-09-25 06:25:16 +10:00
SamG-Coder 9cbefb7e04 feat(kernel): implement tracked UDP sockets and ioctl 2026-09-25 06:23:44 +10:00
SamG-Coder ff725218cb feat(kernel): translate guest IP address conversion APIs 2026-09-25 06:18:32 +10:00
SamG-Coder 97e6ce992b feat(libc): implement guest errno message APIs 2026-09-25 06:17:18 +10:00
SamG-Coder cbf8362251 feat(posix): translate guest address resolution APIs 2026-09-25 06:15:32 +10:00
SamG-Coder dec5841b2d feat(libc): implement caller-backed mspace heaps 2026-09-25 06:10:50 +10:00
SamG-Coder 8a4cc838e0 Merge remote-tracking branch 'upstream/main' into feat/homebrew-game 2026-09-25 06:06:31 +10:00
SamG-Coder 1bbdf7daa6 feat(kernel): support private anonymous guest memory mappings 2026-09-25 06:06:31 +10:00
SamG-Coder 6ba24a895c feat(libs): implement homebrew string compatibility functions 2026-09-25 05:59:07 +10:00
boykopovar 9a4c8eab8b fix(libc): update locale signatures + add sysv abi to math funcs 2026-09-24 22:57:49 +03:00
boykopovar c9a82af00c fix(libc): add guest-compatible c++ locale abi 2026-09-24 10:51:11 +03:00
boykopovar 594656581e feat(libs): add new std symbols + unused filter off by default 2026-09-24 10:28:33 +03:00
boykopovar 9f2b41b9a1 fix(libc): route guest allocations through application heap 2026-09-24 06:53:12 +03:00
boykopovar ed171b23da feat(agc): add driver submission queue and vulkan compute path 2026-09-14 06:37:19 +03:00
boykopovar bd0969c3a4 fix(libs): ex from libc prx: unwind for catch fix (mingw) 2026-09-13 19:21:31 +03:00
boykopovar a1116fe948 feat(libc): windows way for ex handling (wip) 2026-09-11 08:17:12 +03:00
boykopovar ea3f7b5ae0 fix(windows): va_list sysv abi parse for fomatting functions 2026-09-11 07:49:14 +03:00
boykopovar 999a723a5f fix(windows): precommit guest thread stacks to prevent guard page skips 2026-09-10 20:25:25 +03:00
boykopovar b765cefa42 fix(libs): fix args sysv abi for types (windows) 2026-09-10 19:54:03 +03:00
boykopovar fdd7049250 fix(libc): fix ftools exports 2026-09-07 19:54:01 +03:00
boykopovar ba6d7afc22 refactor(libc): __attribute__ replacing and removing 2026-09-06 13:02:22 +03:00
boykopovar baa8a8d9d3 feat(libc): add ex tests + remove bad_alloc dup 2026-09-06 07:30:59 +03:00