Commit Graph

190 Commits

Author SHA1 Message Date
Dean 25c4a9460d
Merge pull request #650 from Celegans12/fix/windows-direct-memory-commit
fix(libkernel): state the size of a direct memory backing Windows cannot create
2026-10-06 08:03:53 +13:00
Dean 78c17a1d47
Merge pull request #661 from NumberGuan/codex/fix-metadata-download-size
fix(libkernel): preserve 64-bit metadata download sizes
2026-10-06 08:03:11 +13:00
Dean e8893dfc64
Merge pull request #633 from Celegans12/feat/kernel-sync-on-address-wait-sized
feat(libkernel): implement sceKernelSyncOnAddressWait32 and sceKernelSyncOnAddressWait64
2026-10-06 08:02:29 +13:00
Dean 17da563b25
Merge pull request #720 from adriadam10/feat/libkernel-unimplemented-names
fix(libkernel): name three Unimplemented stubs from their NIDs
2026-10-06 08:01:33 +13:00
Adrià Franch 6d81cce0db fix(libkernel): name three Unimplemented stubs from their NIDs
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:58:20 +02:00
Adrià Franch 85f16c56ee fix(libkernel): name five sceCoredump stubs from their NIDs
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:55:41 +02:00
Celegans12 62c70fb1d5 fix(libkernel): state the size of a direct memory backing Windows cannot create
On Windows each direct memory allocation is backed by a page-file
section that CreateFileMappingW commits in full. When the system commit
limit cannot cover it, the title stopped with "create direct memory
backing: Insufficient system resources exist to complete the requested
service", which did not say how much was requested.

The error now states the requested size in bytes and MiB, and the
runtime layout notes in USAGE.md describe the commit requirement and
the page file. Allocation behaviour is unchanged: committing at
allocation matches the console, where allocated direct memory is
always backed by physical memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 17:52:04 +02:00
Celegans12 28b2a08fa7 feat(libkernel): implement sceKernelSyncOnAddressWait32 and sceKernelSyncOnAddressWait64
libc's __std_atomic_wait_direct_32 and __std_atomic_wait_direct_64
import these functions, so a libc.prx that contains the C++20 atomic
wait wrappers does not load without them. Wait32 compares a 4-byte
value and Wait64 the full 8-byte value. Both share the waiter queue
of sceKernelSyncOnAddressWait, so sceKernelSyncOnAddressWake releases
waiters of every size on the address. A null address, or one not
aligned to the value size, throws. The by-value comparand, the return
values and the 8-byte alignment of Wait64 are assumed and recorded in
TechnicalDebt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 17:51:32 +02:00
Tomás Ortellado 23008762cc fix(libkernel): preserve 64-bit metadata download sizes 2026-10-05 09:13:05 -03:00
DotDebian 096bdb38c2 fix(libkernel): give CLOCK_VIRTUAL, CLOCK_PROF and CLOCK_SECOND their FreeBSD meaning
clock_gettime and clock_getres served three FreeBSD clock ids with the wrong
clock or not at all:

- CLOCK_VIRTUAL (1) was the monotonic clock on Windows and threw on Linux; it
  is the user CPU time of the process.
- CLOCK_PROF (2) threw on both hosts; it is the user plus system CPU time of
  the process.
- CLOCK_SECOND (13) returned the coarse realtime clock with nanoseconds and a
  sub-second resolution; it is the current second with tv_nsec 0 and a
  resolution of one second.

Behaviour follows FreeBSD 11 clock_gettime(2) and kern_clock_gettime /
kern_clock_getres in sys/kern/kern_time.c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 10:24:22 +02:00
Dean 1a7323ecfc
Merge pull request #549 from Pouare514/fix/reserve-virtual-idempotent
fix(libkernel): idempotent fixed virtual reservation over registered range
2026-10-05 14:20:55 +13:00
Dean 62ed092cc9
Merge pull request #359 from DotDebian/feat/kernel-mlock
feat(libkernel): implement sceKernelMlock
2026-10-05 14:20:14 +13:00
DotDebian 4dea441f01
fix(libkernel): do not expose stale thread-specific values through a reused pthread key
scePthreadKeyDelete frees a key slot and the next scePthreadKeyCreate
hands the same index out again, but every thread kept the value it had
stored under that index. The new key read the previous key's value
instead of NULL, and at thread exit its destructor was called on that
stale pointer.

Each slot now carries a sequence number, as in FreeBSD libthr. A thread
value is visible to scePthreadGetspecific and to the exit destructors
only while its sequence matches the slot's, so a new key starts as NULL
in every thread, as POSIX requires, and a deleted key reads NULL.

scePthreadGetspecific stays lock-free and scePthreadSetspecific no
longer takes the key lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 00:26:20 +00:00
DotDebian 774b34986c
feat(libkernel): implement sceKernelMlock
Lock the guest pages of the range with VirtualLock or mlock, following FreeBSD mlock(2): the range is widened to guest pages, a zero length succeeds, a wrapping range is EINVAL and a range that is not mapped and accessible is ENOMEM. The Windows working set limits and the Linux RLIMIT_MEMLOCK soft limit are raised when the lock needs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 00:25:56 +00:00
Chad 5018b69fba fix(libs): take the AMPR wait and counter signatures from ampr_emu
sceAmprCommandBufferWaitOnAddress took (address, reference, mask,
compare) and WaitOnCounter (counter, reference, compare), and both read
the compare value as WAIT_REG_MEM (0 always, 1 <, 2 <=, 3 ==, ...).
ampr_emu, which replaces libSceAmpr for retail titles on the console,
has (address, reference, compare, flush) and (counter, reference,
compare, flush) with the SCE compare values (0 ==, 1 > unsigned,
2 < unsigned, 3 !=), so waits were decoded as other comparisons and
could block forever or pass early.

WriteAddressFromCounterPairOnCompletion takes one counter index, not
two, and WriteKernelEventQueueOnCompletion an int id and no user data.
Counter indices above 127, compare values above 3, flush values above 1
and misaligned wait addresses return EINVAL, as in ampr_emu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 18:25:45 -05:00
Pouare514 9e0152f18d fix(libkernel): replace mappings on fixed reserve over registered range 2026-10-05 01:21:44 +02:00
Dean c96745e912
Merge pull request #337 from DotDebian/feat/elf-phdr-match-addr
feat(libkernel): implement __elf_phdr_match_addr
2026-10-05 12:10:32 +13:00
Dean dee2727f99
Merge pull request #344 from DotDebian/feat/posix-rwlock-try-timed
feat(libkernel): implement the pthread_rwlock try and timed lock functions
2026-10-05 11:42:29 +13:00
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 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
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 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
Pouare514 5babbe5016 fix(libkernel): support NoOverwrite mappings on Windows 2026-10-04 16:39:24 +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
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 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 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 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
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
RomainROCH eae05782af fix(libkernel): enforce POSIX semaphore count limits 2026-10-03 04:03:25 +02:00
Pouare514 1c724c0228 feat(libs): Cyberpunk 2077 loading support (REDGalaxy + stubs)
# Conflicts:
#	core/libs/prx/libSceContentExport/Export.cpp
#	core/libs/prx/libScePlayGoDialog/Export.cpp
2026-10-02 23:14:04 +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 4181fbd521
Merge pull request #279 from Pouare514/fix/dreaming-sarah-boot
fix(libkernel): boot Dreaming Sarah past unwind and debug raise
2026-10-02 22:38:49 +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 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
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
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
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
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 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