Core: Merge Direct Memory Areas (#3084)

* Merge dmem areas

* Fix DirectMemoryArea::CanMergeWith

Don't merge dmem areas if the memory types are different.

* Reduce some warnings to info

Both functions should behave properly now, there's no reason to warn about their use.

* Clang
This commit is contained in:
Stephen Miller 2025-06-11 09:34:00 -05:00 committed by GitHub
parent 2741829545
commit 3e0ec9ebef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -99,7 +99,7 @@ s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, size_t len) {
s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchEnd,
size_t alignment, u64* physAddrOut,
size_t* sizeOut) {
LOG_WARNING(Kernel_Vmm, "called searchStart = {:#x}, searchEnd = {:#x}, alignment = {:#x}",
LOG_INFO(Kernel_Vmm, "called searchStart = {:#x}, searchEnd = {:#x}, alignment = {:#x}",
searchStart, searchEnd, alignment);
if (physAddrOut == nullptr || sizeOut == nullptr) {
@ -287,7 +287,7 @@ s32 PS4_SYSV_ABI sceKernelMtypeprotect(const void* addr, u64 size, s32 mtype, s3
int PS4_SYSV_ABI sceKernelDirectMemoryQuery(u64 offset, int flags, OrbisQueryInfo* query_info,
size_t infoSize) {
LOG_WARNING(Kernel_Vmm, "called offset = {:#x}, flags = {:#x}", offset, flags);
LOG_INFO(Kernel_Vmm, "called offset = {:#x}, flags = {:#x}", offset, flags);
auto* memory = Core::Memory::Instance();
return memory->DirectMemoryQuery(offset, flags == 1, query_info);
}

View file

@ -222,6 +222,7 @@ PAddr MemoryManager::Allocate(PAddr search_start, PAddr search_end, size_t size,
auto& area = CarveDmemArea(mapping_start, size)->second;
area.memory_type = memory_type;
area.is_free = false;
MergeAdjacent(dmem_map, dmem_area);
return mapping_start;
}

View file

@ -75,6 +75,9 @@ struct DirectMemoryArea {
if (base + size != next.base) {
return false;
}
if (memory_type != next.memory_type) {
return false;
}
if (is_free != next.is_free) {
return false;
}