mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-25 20:28:48 +08:00
Add missing nids (#450)
* [Kernel] Implement clock_getres and the POSIX pthread_once alias clock_getres (smIj7eqzZE8) was missing entirely. It reports 100ns, which is the resolution clock_gettime here actually delivers via DateTimeOffset.UtcNow, rather than claiming the 1ns a caller might otherwise rely on. A null res pointer is accepted per POSIX. pthread_once (Z4QosVuAsA0) needed no new logic: libKernel exports the same routine under two NIDs and only scePthreadOnce (14bOACANTBo) was registered. Shipped middleware links the plain name. Both are imported by DOOM + DOOM II (PPSA21444): clock_getres blocked party.prx from initialising, and pthread_once is used by libcohtml, libPlayFabMultiplayer, party.prx and the eboot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit848f035827) * [Libs] Implement sceAgcGetIsTrinityMode, NpReachability and Trophy2 info Three exports DOOM + DOOM II (PPSA21444) imports and currently receives unresolved-stub errors for. sceAgcGetIsTrinityMode reports the base console this backend emulates. It returns the flag in rax and writes no guest memory: the observed rdi at the call site sits inside the AGC state block, immediately below the shader handles the guest stores, so writing through it would corrupt live state if that register is stale rather than an out-pointer. sceNpRegisterNpReachabilityStateCallback accepts the callback and never fires it, matching the existing sceNpRegisterStateCallback handling. Reachability transitions only occur on a live PSN connection. sceNpTrophy2GetTrophyInfo reports NOT_FOUND rather than success. Succeeding requires filling SceNpTrophy2Details and SceNpTrophy2Data, whose layouts are not confirmed here, and a title trusting zeroed details would read an empty name and grade 0 as real data. NOT_FOUND is a documented outcome callers already handle. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit181286f621) * [Kernel] Implement the POSIX libKernel exports titles link directly libKernel exports many routines under both sce-prefixed and plain POSIX NIDs, and shipped middleware links the latter. These nine are imported by DOOM + DOOM II (PPSA21444) and had no registration at all. Aliases onto existing implementations, identical argument order: mprotect (YQOfxL4QfeU), munmap (UqDGjXA5yUM), setsockopt (fFxGkxF2bVo) New: getpagesize reports OrbisPageSize (16 KiB), not the host 4 KiB. An allocator rounding to the host value produces sub-page offsets that every mapping call here rejects for misalignment. pthread_rwlock_tryrdlock/trywrlock get a dedicated non-blocking core. They deliberately do not reuse TryAcquireBlockedRwlock, which decrements WaitingWriters -- correct only for a thread that previously incremented it. A fresh try never did, so reusing it would consume another thread's waiter count and let a queued writer be skipped. getsockopt reads back the three options this backend tracks (SO_NBIO, SO_REUSEADDR, SO_ERROR) and rejects the rest rather than returning success with an untouched buffer the caller would treat as real. send maps WouldBlock onto the existing net error path. inet_ntop converts AF_INET/AF_INET6 and returns the destination pointer per POSIX, failing rather than truncating when it will not fit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit98c6851840) * [Kernel] Implement the POSIX mprotect, munmap and getpagesize aliases mprotect and munmap forward to the existing sceKernelMprotect and sceKernelMunmap; the argument order is identical, so they are plain aliases rather than separate implementations. getpagesize reports OrbisPageSize (16 KiB), the granularity this backend maps and aligns against, not the host's 4 KiB. An allocator that rounded to the host value would produce sub-page offsets that every mapping call here then rejects for misalignment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [Kernel] Implement the POSIX _nanosleep symbol libKernel exports nanosleep under two NIDs: yS8U2TGCe1A for the plain name and NhpspxdjEKU for the underscore-prefixed _nanosleep that libc conventionally provides alongside it. Only the former was registered. Both are POSIX-side symbols, so this shares NanosleepCore with posix: true - reporting failure as -1 plus errno rather than returning an OrbisGen2Result the way sceKernelNanosleep does. Not exercised at runtime: no title currently on this branch imports _nanosleep, so the choice of error convention rests on it being the same libc routine as nanosleep, not on observed behaviour. * [Kernel] Implement the POSIX-named pthread aliases libKernel exports each of these routines under two NIDs: a scePthread* name and the plain POSIX name. Only the scePthread* half was registered, so middleware compiled against POSIX headers linked an unresolved stub. Adds the POSIX-named export for fourteen routines, each delegating to the existing implementation: pthread_setprio pthread_attr_setschedpolicy pthread_getschedparam pthread_attr_setdetachstate pthread_attr_getschedparam pthread_attr_setschedparam pthread_attr_getstack pthread_attr_setinheritsched pthread_attr_get_np pthread_attr_setguardsize pthread_attr_getstacksize pthread_attr_getguardsize pthread_attr_getdetachstate pthread_rename_np Arguments are identical in both forms, and per the convention set by scePthreadOnce's alias the POSIX name returns the same OrbisGen2Result rather than translating to errno. The equivalent POSIX names for mkdir, listen, accept and recv are deliberately not included here. Those pair with sceKernelMkdir and the libSceNet entry points, whose error convention differs from the POSIX one, so they need a decision about error translation rather than a straight delegation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -578,6 +578,30 @@ public static class KernelPthreadCompatExports
|
||||
return SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The POSIX-named alias of <see cref="PthreadOnce"/>. libKernel exports the
|
||||
/// same routine under two NIDs, and shipped middleware links the plain name:
|
||||
/// DOOM's libcohtml, PlayFab and party modules all import this one rather
|
||||
/// than scePthreadOnce.
|
||||
/// </summary>
|
||||
[SysAbiExport(
|
||||
Nid = "Z4QosVuAsA0",
|
||||
ExportName = "pthread_once",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libKernel")]
|
||||
public static int PthreadOncePOSIX(CpuContext ctx) => PthreadOnce(ctx);
|
||||
|
||||
/// <summary>
|
||||
/// The POSIX-named alias of <see cref="PthreadRename"/>, following the same
|
||||
/// two-NID pattern as <see cref="PthreadOncePOSIX"/>.
|
||||
/// </summary>
|
||||
[SysAbiExport(
|
||||
Nid = "9vyP6Z7bqzc",
|
||||
ExportName = "pthread_rename_np",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libKernel")]
|
||||
public static int PthreadRenameNpPOSIX(CpuContext ctx) => PthreadRename(ctx);
|
||||
|
||||
private static int PthreadMutexInitCore(CpuContext ctx, ulong mutexAddress, ulong attrAddress)
|
||||
{
|
||||
if (mutexAddress == 0)
|
||||
|
||||
Reference in New Issue
Block a user