Skip to content

Libs: add libSceDiscMap HLE exports - #79

Merged
par274 merged 1 commit into
sharpemu:mainfrom
j92580498-max:hle-discmap
Jul 12, 2026
Merged

Libs: add libSceDiscMap HLE exports#79
par274 merged 1 commit into
sharpemu:mainfrom
j92580498-max:hle-discmap

Conversation

@j92580498-max

Copy link
Copy Markdown
Contributor

What

Adds an HLE implementation of libSceDiscMap as a new DiscMapExports class in SharpEmu.Libs, following the existing SysAbiExport conventions (validated pointers, OrbisGen2Result codes, optional env-gated tracing).

Disc-installed titles call into libSceDiscMap on most file accesses to decide whether a read has to be redirected to the Blu-ray drive. Without these exports the imports resolve to ORBIS_GEN2_ERROR_NOT_FOUND, which titles can treat as an I/O failure. Reporting every request as already resident on internal storage keeps reads on the regular file system path.

Exports

NID Export Behavior
lbQKqsERhtE sceDiscMapIsRequestOnHDD writes 1 to the result pointer, returns 0
fJgP+wqifno sceDiscMapUnknownFJgP zero-fills the three output pointers, returns 0
ioKMruft1ek sceDiscMapUnknownIoKM zero-fills the three output pointers, returns 0
  • Null path/output pointers return DISC_MAP_ERROR_INVALID_ARGUMENT (0x81100001), consistent with the known 0x811000xx libSceDiscMap error range.
  • Unreadable/unwritable guest memory returns ORBIS_GEN2_ERROR_MEMORY_FAULT.
  • Set SHARPEMU_LOG_DISCMAP=1 to trace calls (path, offset, size), matching the SHARPEMU_LOG_PTHREADS pattern.
  • sceDiscMapIsRequestOnHDD is already in scripts/ps5_names.txt, so Aerolib resolves the name; the two unidentified NIDs keep descriptive Unknown export names like the existing sceKernelUnknown* entries.

Source / attribution

Behavior is ported from the LibDiscMap.cpp stubs in Kyty (MIT), rewritten in C# for SharpEmu's export model. shadPS4's HLE discmap work was used as a cross-reference for the argument layout of the two unidentified NIDs (path, offset, nbytes, three out-pointers). This PR was prepared with the help of an AI assistant; flagging that for the maintainers' awareness.

Testing

  • dotnet build SharpEmu.slnx — clean, 0 warnings / 0 errors (SDK 10.0.103)
  • Verified via a small harness against ModuleManager.RegisterFromAssembly: all three NIDs register and dispatch, sceDiscMapIsRequestOnHDD writes 1 and returns 0, null-pointer calls return 0x81100001, and the triple-output NIDs zero their out-params.

No existing NIDs are touched; the change is purely additive.

Port the libSceDiscMap stubs from Kyty (InoriRus/Kyty, MIT) into the
SysAbiExport model. Disc-installed titles probe these NIDs on most file
accesses to decide whether a read must be redirected to the disc drive;
answering that every request is already resident on internal storage
keeps I/O on the regular file system path instead of failing with
unresolved-import errors.

- sceDiscMapIsRequestOnHDD (lbQKqsERhtE): validates args, writes 1 to
  the result pointer, returns 0
- fJgP+wqifno / ioKMruft1ek: zero-fill the three output pointers,
  return 0 (names not present in ps5_names.txt; kept as descriptive
  Unknown exports like the existing sceKernelUnknown* convention)
- DISC_MAP_ERROR_INVALID_ARGUMENT (0x81100001) on null pointers,
  matching the documented libSceDiscMap error range
- optional tracing via SHARPEMU_LOG_DISCMAP=1
@Nmzik

Nmzik commented Jul 12, 2026

Copy link
Copy Markdown

@par274 If I remember correctly, this ABI/API (DiscMap) is only available on the PS4, not the PS5

@par274

par274 commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

These may be leftovers on the PS5. The real question is: which game called them?

@j92580498-max

Copy link
Copy Markdown
Contributor Author

It is actually used on the PlayStation 5. I looked through the PS5-3.20_Libs, and there's a file called libSceDiscMap

@par274

par274 commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Yes, that's correct. I don't know whether any games actually call them, but they shouldn't hurt the semantics

@par274
par274 merged commit 5aadb74 into sharpemu:main Jul 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants