mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
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>
This commit is contained in:
@@ -175,6 +175,10 @@ int32_t APS5_VABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, size_t len
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t APS5_VABI sceKernelMapNamedFlexibleMemoryInternal(void** addr_in_out, size_t len, int prot, int flags, const char* name) {
|
||||
return sceKernelMapNamedFlexibleMemory(addr_in_out, len, prot, flags, name);
|
||||
}
|
||||
|
||||
int APS5_VABI sceKernelMprotect(const void* addr, size_t len, int prot) {
|
||||
return DoMprotect(addr, len, prot);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ void* APS5_VABI mmap_nid_postfix(void*, std::size_t, int, int, int, std::int64_t
|
||||
int APS5_VABI munmap_nid_postfix(void*, std::size_t) noexcept;
|
||||
int* APS5_VABI __error_nid_postfix();
|
||||
int APS5_VABI sceKernelMapNamedFlexibleMemory(void**, std::size_t, int, int, const char*);
|
||||
int APS5_VABI sceKernelMapNamedFlexibleMemoryInternal(void**, std::size_t, int, int, const char*);
|
||||
int APS5_VABI sceKernelAvailableFlexibleMemorySize(std::size_t*);
|
||||
int APS5_VABI sceKernelMapFlexibleMemory(void**, std::size_t, int, int);
|
||||
int APS5_VABI sceKernelMunmap(void*, std::size_t);
|
||||
int APS5_VABI sceKernelMprotect(const void*, std::size_t, int);
|
||||
@@ -78,6 +80,24 @@ static void CheckNamedAndHintedMappings() {
|
||||
Require(sceKernelMunmap(first, length) == 0);
|
||||
}
|
||||
|
||||
static void CheckInternalNamedFlexibleMapping() {
|
||||
constexpr std::size_t length = 0x10000;
|
||||
std::size_t before = 0;
|
||||
std::size_t available = 0;
|
||||
Require(sceKernelAvailableFlexibleMemorySize(&before) == 0);
|
||||
void* mapped = nullptr;
|
||||
Require(sceKernelMapNamedFlexibleMemoryInternal(&mapped, length, 3, 0, "internal mapping") == 0 && mapped != nullptr);
|
||||
Require(std::strcmp(NameAt(mapped), "internal mapping") == 0);
|
||||
Require(sceKernelAvailableFlexibleMemorySize(&available) == 0 && available == before - length);
|
||||
Require(sceKernelMunmap(mapped, length) == 0);
|
||||
Require(sceKernelAvailableFlexibleMemorySize(&available) == 0 && available == before);
|
||||
bool rejected = false;
|
||||
void* unknown = nullptr;
|
||||
try { sceKernelMapNamedFlexibleMemoryInternal(&unknown, length, 3, 0x8000, "internal mapping"); } catch (const std::exception&) { rejected = true; }
|
||||
Require(rejected && unknown == nullptr);
|
||||
Require(sceKernelAvailableFlexibleMemorySize(&available) == 0 && available == before);
|
||||
}
|
||||
|
||||
static void CheckDirectMemoryFollowsPhysicalPages() {
|
||||
constexpr std::size_t page = 0x4000;
|
||||
std::int64_t phys = 0;
|
||||
@@ -452,6 +472,7 @@ static void CheckDirectMemoryWriteWatch() {
|
||||
|
||||
int main() {
|
||||
CheckNamedAndHintedMappings();
|
||||
CheckInternalNamedFlexibleMapping();
|
||||
CheckDirectMemoryFollowsPhysicalPages();
|
||||
CheckFixedVirtualReservation();
|
||||
CheckSharedDirectMemoryLifecycle();
|
||||
|
||||
@@ -28,6 +28,7 @@ Throughout the project, every function at every stage either **does exactly what
|
||||
- [V++UgBtQhn0](../../core/libs/prx/libSceAgc/Misc/src/PacketInfo.cpp) (libSceAgc) - unknown name
|
||||
- [gQkqkLttcpw](../../core/libs/prx/libSceAgc/Acb/src/Control.cpp) (libSceAgc) - unknown name, signature
|
||||
- [sceKernelInternalMemoryGetModuleSegmentInfo](../../core/libs/prx/libkernel/Module/src/Module.cpp) (libkernel) - unknown signature
|
||||
- [sceKernelMapNamedFlexibleMemoryInternal](../../core/libs/prx/libkernel/DirectMemory/Export.cpp) (libkernel) - flag 0x8000 unknown; only the sceKernelMapNamedFlexibleMemory flags are accepted
|
||||
- [sceLibcInternalBacktraceForGame](../../core/libs/prx/libc/src/HeapDiagnostics.cpp) (libSceLibcInternal, implemented in libc) - unknown signature
|
||||
- [sceLibcInternalHeapErrorReportForGame](../../core/libs/prx/libc/src/HeapDiagnostics.cpp) (libSceLibcInternal, implemented in libc) - unknown signature
|
||||
- [__progname](../../core/libs/prx/libkernel/System/src/Process.cpp) (libkernel) - unknown data export
|
||||
|
||||
Reference in New Issue
Block a user