Commit Graph
61 Commits
Author SHA1 Message Date
Dean efed902d27 Merge pull request #10936 from AdnanKhan-ak47/fix/ampr-nop-encoding
fix(libSceAmpr): record Nop as n dwords with a one-dword header
2026-10-27 21:15:40 +13:00
Adnan Khan 0d14468ccc fix(libSceAmpr): zero the padding of a constructed Nop payload 2026-10-25 22:56:04 +05:30
Adnan Khan ada5ad0990 fix(libSceAmpr): write the console's Nop header word and report a null base first 2026-10-25 22:46:51 +05:30
Adnan Khan dc510a5279 fix(libSceAmpr): record Nop as n dwords with a one-dword header 2026-10-25 16:32:53 +05:30
Yunus Shaikh d689d1b59c refactor(libSceAmpr): share the AMM map, unmap, remap and protection encoders
The range, direct offset and protection checks of the AMM map, unmap,
remap, multimap and protection commands, and the records they build,
move from libSceAmpr's Export.cpp into the APR command buffer header
that libSceAmpr and libkernel already share. libSceAmpr records the
same bytes and returns the same errors in the same order; the kernel
writers can now encode the same records without a second copy.
2026-10-25 00:02:34 +00:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
blu 2a796cb447 Merge branch 'boykopovar:main' into feat/libc-num-get-objects 2026-10-21 19:03:38 -07:00
boykopovar d9c2facdb9 fix(ampr): preserve nop payload when data is absent 2026-10-21 21:52:56 +03:00
bluandClaude Fable 5.1 46c36c304f feat(libc): export the num_get and time_get locale objects as data
The public SDK's libSceLibcInternal table declares num_get<char>::id, time_get<char>::id and the
num_get<char> vtable as objects; libSceAmpr exported their NIDs as functions that throw, which a
data consumer reads as code (#8875). libc now defines them the way the other facet ids and the
num_put and codecvt vtables are kept: the ids zero, the vtable 15 zeroed slots (two header
entries, the two destructor entries and Dinkumware's eleven do_get), and libSceAmpr drops the
functions. An import qualified to libSceAmpr.prx falls back to libc, so each object has one
identity.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-20 21:13:08 -07:00
Sam fa379c0766 Merge remote-tracking branch 'origin/main' into feat/libc-wcstombs-s
# Conflicts:
#	core/libs/prx/libSceAmpr/Export.cpp
2026-10-20 19:28:46 +02:00
Dean 0b1d678fe5 Merge pull request #8148 from hamb3r/feat/libc-dinkumware-threads
feat(libc): export Dinkumware thread primitives from libc.prx
2026-10-21 06:21:49 +13:00
Sam ab8cb4f9ad feat(libc): export wcstombs_s
libc.prx did not export wcstombs_s (sZLrjx-yEx4); only libSceAmpr did.
Ghost of Yotei imports it from libc.prx and stops at symbol resolution.

Move the implementation to libc next to wcsrtombs_s. libSceAmpr keeps
its export through an explicit-NID wrapper, because the NID patcher
leaves symbols that libc exports unrenamed in other libraries.
2026-10-20 14:12:11 +02:00
hamb3r 3524b04740 feat(libc): move Dinkumware thread exports from libSceAmpr to libc 2026-10-20 03:22:00 +03:00
lakhantheboss 2873e9c361 fix(ampr): validate null command buffer arguments 2026-10-19 18:39:10 +02:00
hugodearaujo 12813101d2 fix(ampr): return EBUSY when a command does not fit and EPERM before a buffer is bound 2026-10-17 19:23:26 -03:00
KernelPanicNTandClaude Opus 5.5 5b7e3aea8b feat(libSceAmpr): implement __cxa_call_unexpected
__cxa_call_unexpected takes the in-flight exception's unwind header and
never returns, as in libcxxabi. No std::set_unexpected is exported and
the exception header's unexpected handler is never set, so the handler
is always the default one, which calls std::terminate. It therefore
forwards to libc's __cxa_call_terminate, which begins the catch and runs
the current terminate handler; a null header terminates in libc's
__cxa_begin_catch. libcxxabi's std::terminate would instead run the
terminate handler saved in the exception header at throw time; the two
differ only if std::set_terminate was called in between, which the debt
entry records.

The test shares the forked-child helper of the std::_Pad test, which now
takes the terminate handler to install.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 11:31:15 +00:00
hamb3r 8652dbe35b feat(libc): add missing Unity IL2CPP runtime imports and Dinkumware helpers
Add missing libc.prx symbols required by Unity IL2CPP runtime:
- Implement _Dtest double classification in Math.cpp
- Implement _Inf double constant in Math.cpp
- Implement sceLibcBacktraceGetBufferSize and sceLibcBacktraceSelf in Backtrace.cpp
- Implement _Cnd_signal in Threads.cpp
- Implement _ZNSt8ios_base7_AddstdEPS_ in RuntimeSupport.cpp
- Implement __pointer_type_info and __function_type_info vtables in TypeInfo.cpp
- Remove duplicate stubs from libSceAmpr/Export.cpp
- Add unit tests in GuestMath.cpp and GuestLibcThreads.cpp
- Document unverified behaviors in docs/dev/debt/libc.md
2026-10-13 19:01:30 +03:00
Adrià 1e7f4967ed Merge pull request #3743 from YossiYad/carry/ampr-pad-launch
feat(libSceAmpr): implement the std::_Pad thread launch helpers
2026-10-13 15:15:37 +02:00
Yossi Yadgar dd1deb6965 fix(ampr): raise std::_Pad failures as the guest std::system_error
A failing _Pad primitive threw a host std::runtime_error, which no guest
catch can see. threadcall.cpp calls the checked wrappers of xthread
(_Mtx_lockX, _Cnd_waitX, _Thrd_startX), which pass a non-success code to
_Throw_C_error: _Thrd_nomem and _Thrd_timedout become
resource_unavailable_try_again, _Thrd_busy device_or_resource_busy and
_Thrd_error invalid_argument, raised through _Throw_Cpp_error, which main
now implements. A failing thread start is _Thrd_startX's
resource_unavailable_try_again.

_Release now wakes the launching thread with _Cnd_signal, as
threadcall.cpp does; libc has it since the pad was written.

guest_ampr_threads checks, in a forked child whose guest terminate
handler reports the thrown object, that _Release on the thread still
holding the pad's mutex throws std::system_error with EBUSY. It fails
with the previous host exception and with busy mapped to
invalid_argument.
2026-10-13 15:59:28 +03:00
Yossi Yadgar 8e3b2a06f2 fix(ampr): exclude the private pad entry from the export inventory 2026-10-13 15:51:00 +03:00
DavidandClaude Fable 5.1 d991cdccf9 feat(libSceAmpr): implement the std::_Pad thread launch helpers
Implement _ZNSt4_PadC2Ev, _ZNSt4_PadD2Ev, _ZNSt4_Pad7_LaunchEPP7pthread
and _ZNSt4_Pad8_ReleaseEv, which Deathloop (PPSA01670) and Minecraft
Legends (PPSA05510) import from libSceAmpr for the std::thread launch path.

The algorithm and object layout follow Dinkumware V6.00 thr/xthread and
thr/threadcall.cpp of Visual C++ 2013 (ganboing/crt.vc12 f1d47126): a
vtable pointer whose first slot is the pure virtual _Go(), then the
condition and mutex handles and bool _Started (0x8, 0x10, 0x18), with the
console's pointer-to-slot handles of libc Threads.cpp (#3079). The pad
uses libc's _Cnd_*/_Mtx_* exports, starts the guest thread with
pthread_create and an entry that calls _Go() and returns its result as
the exit code, as _Call_func does. The unverified layout, thread
attributes and error reporting are recorded in TechnicalDebt.md.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-13 15:51:00 +03:00
Evgeniy Kazarin e3cef332e6 feat(libc): implement generic error category messages 2026-10-13 14:38:04 +03:00
Adrià 955f4fbffe Merge pull request #4207 from xXPBSXx/fix/ampr-amm-usage-stats
feat(libSceAmpr): answer sceAmprAmmGetUsageStatsData
2026-10-12 22:57:04 +02:00
Adrià 999c07a633 Merge pull request #3890 from MarcZX100/codex/carry-ampr-offset-bounds-3321
fix(ampr): reject command buffer offsets beyond bound memory
2026-10-12 22:48:32 +02:00
xXPBSXxandClaude Sonnet 5.5 4b6f463751 feat(libSceAmpr): answer sceAmprAmmGetUsageStatsData
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-12 21:14:14 +02:00
David 2dc4d9d65c feat(libSceAmpr): implement std::_Throw_Cpp_error
Throw a guest std::system_error for the Dinkumware _Cpp_error codes,
as in VC12 and microsoft/STL thread0.cpp: the error_code holds the
FreeBSD errno and a guest generic error category modelled in libc, and
what() is the table message followed by the category message. Codes
outside the table throw std::out_of_range. The system_error copy
constructor and assignment now copy the error_code too.

Imported by Deathloop (PPSA01670) and Minecraft Legends (PPSA05510).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit bed1deafdee4b50bea9683a1cead0d0320150eb7)
2026-10-12 18:46:43 +00:00
Blazing Cook c20583bd34 fix(ampr): reject command buffer offsets beyond bound memory
(cherry picked from commit b92287dc68d538d44369d2a09500b4404ca53fca)
2026-10-12 18:45:58 +00:00
Dean 9b20dd58c0 Merge pull request #4251 from Dextroid17/fix/libampr-usage-stats-stubs
fix(libSceAmpr): export sceAmprAmmSetPageTablePoolOccupancyNotificationThreshold
2026-10-13 01:23:06 +13:00
Dean 732fc01aaf Merge pull request #3814 from xXPBSXx/fix/export-ppsa30601-imports
fix(exports): export the calls PPSA30601 imports
2026-10-12 21:36:02 +13:00
Dextroid17 ef3b121e44 fix(libSceAmpr): export sceAmprAmmSetPageTablePoolOccupancyNotificationThreshold
Resolves NID touqMEt6qXQ, the last import Trails in the Sky 2nd Chapter
(PPSA35169) is left missing on libSceAmpr.prx once the libkernel pair in #4214
is recorded. No reference describes the function's contract, so it throws via
the project's NotImplemented_nid_no_patch pattern rather than guessing a result
that a caller would act on.

sceAmprAmmGetUsageStatsData (KqiWXLgCVe0) is deliberately not included: #3814
exports it and #4207 answers it from a cited layout.

See issue #4214.
2026-10-11 23:23:44 -04:00
xXPBSXx 35a6df818f Merge remote-tracking branch 'upstream/main' into fix/export-ppsa30601-imports
# Conflicts:
#	core/libs/prx/libSceJson2/Export.cpp
#	docs/dev/TechnicalDebt.md
2026-10-12 01:19:36 +02:00
hamb3r b8a1cbe42b fix(libc): add missing Unity engine static imports 2026-10-12 01:04:39 +03:00
Dean abd318d9c0 Merge pull request #3683 from Zurisen/fix/amm-below-host-regions
fix(libkernel): reserve the AMM ranges below host regions at the top of the guest arena
2026-10-12 10:43:07 +13:00
xXPBSXxandClaude Sonnet 5.5 d7bf16a054 fix(exports): export the calls PPSA30601 imports
PPSA30601 (Resonance: A Plague Tale Legacy) fails to load without these imports that no library exports. Their signatures are unknown, so they are declared without parameters and throw until they are implemented. Adds a TechnicalDebt entry.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-11 19:02:18 +02:00
Zurisen 3c6c5d5331 fix(libkernel): reserve the AMM ranges below host regions at the top of the guest arena
The AMM ranges were reserved at the last 64 GiB of the guest arena and
the reservation threw when that window was not free. On Windows the
stacks of the threads that exist before the arena is reserved (the main
thread and the loader's workers) are placed at random addresses and are
left in the arena as host regions; when one fell in the last 64 GiB, the
first AMM use threw "fixed guest mapping ... overlaps a host region in
the guest arena". Reserve the highest free 64 GiB window instead: the
last 64 GiB when it is free, and the window just below an occupied part
of it otherwise.
2026-10-11 17:09:12 +02:00
DavidandClaude Fable 5.1 dce174749d feat(libSceAmpr): implement _Cnd_signal and _Cnd_init_with_name
Deathloop (PPSA01670), Minecraft Legends (PPSA05510) and GTA III
Definitive Edition import both from libSceAmpr. They take a pointer to
the handle slot and act on the conditions created by the libc _Cnd_init:
_Cnd_signal wakes one waiter through a libc helper, _Cnd_init_with_name
is _Cnd_init with the name ignored. _Thrd_id still throws.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-11 13:41:49 +02:00
Pouare514 5290f92876 fix(libs): share Sony CRT semantics between libc and libSceAmpr with tests 2026-10-11 11:42:31 +02:00
tototomate123 65c8ef656f fix(apr): compact gather records to avoid command buffer exhaustion 2026-10-11 07:27:52 +02:00
tototomate123 f514df98de fix(apr): match the guest command buffer object layout 2026-10-11 07:27:52 +02:00
Adrià Franch fddcb00a40 fix(libSceAmpr): give _Thrd_sleep the console signature and move its TechnicalDebt line
The title's libc.prx _Thrd_sleep takes a second xtime* (remaining) and returns int.
The TechnicalDebt entry no longer sits at the end of its section.
2026-10-11 00:01:46 +02:00
DavidandClaude Fable 5.1 b446119c76 feat(libSceAmpr): implement the Dinkumware thread, sleep and spin lock exports
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-11 00:01:28 +02:00
Pouare514 998016e789 fix(libs): drop stubs now owned by main after rebase 2026-10-09 20:13:56 +02:00
Pouare514 c67189fdee fix(libs): export host-colliding runtime names via _nid_postfix 2026-10-09 20:12:46 +02:00
Pouare514 b6c70b1135 fix(libs): rename loader stubs to recomputed real names, drop clashing ones 2026-10-09 20:12:31 +02:00
Pouare514 e96ec6da7d feat(libs): Deathloop loading support (Ampr, NetCtlApDialog, Party + stubs) 2026-10-09 20:11:35 +02:00
jdmagicandClaude Opus 5.5 8ae350caaa fix(libSceAmpr): sceAmprCommandBufferClearBuffer returns the detached buffer
sceAmprCommandBufferClearBuffer detaches a command buffer's memory and
returns it so the caller can free it. It returned 0. PPSA01289 (Sackboy: A
Big Adventure) frees the result after every streaming read, so each read
leaked its 16 KiB command buffer until the allocator ran out of memory
during the first world load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 01:58:38 -04:00
Claude 121d9332b5 build(libs): strip the MinGW static runtime flags once for all libraries
Every library CMakeLists.txt ended with the same block removing -static,
-static-libgcc and -static-libstdc++ from CMAKE_EXE_LINKER_FLAGS on MinGW,
because core/libs/CMakeLists.txt only removed them after adding the library
directories. Remove them before the libc and library directories are added
so each directory inherits the stripped flags, and drop the 52 copies.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017pTZqAyVSZy2FZmaqakPHZ
2026-10-07 10:10:38 +00:00
ChadandClaude Opus 5.5 cf3d0f6fc7 feat(libs): implement the AMM PRT commands
sceAmprAmmCommandBufferMapAsPrt, AllocatePaForPrt, RemapIntoPrt and
UnmapToPrt, with the MapAsPrt and AllocatePaForPrt measures. Signatures,
checks and their order follow ampr_emu.

The executor keeps the PRT pages of the AMM ranges. Unbacked PRT pages
are zero-filled with GPU read access; AllocatePaForPrt backs each
unbacked page with a pool page and changes the type and protection of
backed ones; RemapIntoPrt moves a mapped range into a PRT range; and
UnmapToPrt returns the pages to the pool and zero-fills them again. A
plain map, unmap or remap over a PRT range ends it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 15:45:28 -05:00
Chad 6c21041d0d Merge branch 'feat/amm-core' into feat/amm-remap-protect 2026-10-05 15:41:57 -05:00
ChadandClaude Opus 5.5 0cb5ca7203 fix(libs): take the AMM submit checks from ampr_emu
The AMM submit forms now return EINVAL for a priority above 2 and EPERM
for a null command buffer, in that order, as ampr_emu's
amm_validate_submit_args does, instead of EINVAL for a null buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 15:41:49 -05:00