mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-14 14:43:15 +00:00
Implement sceKernelMapDirectMemory2 (#2940)
* Implement sceKernelMapDirectMemory2 Behaves similarly to sceKernelMapDirectMemory, but has a type parameter. * Simplify No need to copy all the MapDirectMemory code over, can just call the function, then do the SetDirectMemoryType call * Clang
This commit is contained in:
parent
aeb4536988
commit
18ff65efc8
3 changed files with 29 additions and 0 deletions
|
@ -209,6 +209,19 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
|
|||
"anon");
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceKernelMapDirectMemory2(void** addr, u64 len, s32 type, s32 prot, s32 flags,
|
||||
s64 phys_addr, u64 alignment) {
|
||||
LOG_INFO(Kernel_Vmm, "called, redirected to sceKernelMapNamedDirectMemory");
|
||||
const s32 ret =
|
||||
sceKernelMapNamedDirectMemory(addr, len, prot, flags, phys_addr, alignment, "anon");
|
||||
|
||||
if (ret == 0) {
|
||||
auto* memory = Core::Memory::Instance();
|
||||
memory->SetDirectMemoryType(phys_addr, type);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceKernelMapNamedFlexibleMemory(void** addr_in_out, std::size_t len, int prot,
|
||||
int flags, const char* name) {
|
||||
|
||||
|
@ -645,6 +658,7 @@ void RegisterMemory(Core::Loader::SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("yDBwVAolDgg", "libkernel", 1, "libkernel", 1, 1, sceKernelIsStack);
|
||||
LIB_FUNCTION("NcaWUxfMNIQ", "libkernel", 1, "libkernel", 1, 1, sceKernelMapNamedDirectMemory);
|
||||
LIB_FUNCTION("L-Q3LEjIbgA", "libkernel", 1, "libkernel", 1, 1, sceKernelMapDirectMemory);
|
||||
LIB_FUNCTION("BQQniolj9tQ", "libkernel", 1, "libkernel", 1, 1, sceKernelMapDirectMemory2);
|
||||
LIB_FUNCTION("WFcfL2lzido", "libkernel", 1, "libkernel", 1, 1, sceKernelQueryMemoryProtection);
|
||||
LIB_FUNCTION("BHouLQzh0X0", "libkernel", 1, "libkernel", 1, 1, sceKernelDirectMemoryQuery);
|
||||
LIB_FUNCTION("MBuItvba6z8", "libkernel", 1, "libkernel", 1, 1, sceKernelReleaseDirectMemory);
|
||||
|
|
|
@ -783,6 +783,19 @@ int MemoryManager::DirectQueryAvailable(PAddr search_start, PAddr search_end, si
|
|||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s32 MemoryManager::SetDirectMemoryType(s64 phys_addr, s32 memory_type) {
|
||||
std::scoped_lock lk{mutex};
|
||||
|
||||
auto& dmem_area = FindDmemArea(phys_addr)->second;
|
||||
|
||||
ASSERT_MSG(phys_addr <= dmem_area.GetEnd() && !dmem_area.is_free,
|
||||
"Direct memory area is not mapped");
|
||||
|
||||
dmem_area.memory_type = memory_type;
|
||||
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
void MemoryManager::NameVirtualRange(VAddr virtual_addr, size_t size, std::string_view name) {
|
||||
auto it = FindVMA(virtual_addr);
|
||||
|
||||
|
|
|
@ -219,6 +219,8 @@ public:
|
|||
int GetDirectMemoryType(PAddr addr, int* directMemoryTypeOut, void** directMemoryStartOut,
|
||||
void** directMemoryEndOut);
|
||||
|
||||
s32 SetDirectMemoryType(s64 phys_addr, s32 memory_type);
|
||||
|
||||
void NameVirtualRange(VAddr virtual_addr, size_t size, std::string_view name);
|
||||
|
||||
void InvalidateMemory(VAddr addr, u64 size) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue