diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index a24a08be2e67..c11966f0d972 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -53,7 +53,7 @@ error_code sys_mmapper_allocate_fixed_address() { sys_mmapper.error("sys_mmapper_allocate_fixed_address()"); - if (!vm::map(0xB0000000, 0x10000000)) // TODO: set correct flags (they aren't used currently though) + if (!vm::map(0xB0000000, 0x10000000, SYS_MEMORY_PAGE_SIZE_1M)) { return CELL_EEXIST; } @@ -228,7 +228,7 @@ error_code sys_mmapper_free_shared_memory(u32 mem_id) error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags) { - sys_mmapper.error("sys_mmapper_map_shared_memory(addr=0x%x, mem_id=0x%x, flags=0x%llx)", addr, mem_id, flags); + sys_mmapper.warning("sys_mmapper_map_shared_memory(addr=0x%x, mem_id=0x%x, flags=0x%llx)", addr, mem_id, flags); const auto area = vm::get(vm::any, addr); @@ -267,7 +267,7 @@ error_code sys_mmapper_map_shared_memory(u32 addr, u32 mem_id, u64 flags) error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, vm::ptr alloc_addr) { - sys_mmapper.error("sys_mmapper_search_and_map(start_addr=0x%x, mem_id=0x%x, flags=0x%llx, alloc_addr=*0x%x)", start_addr, mem_id, flags, alloc_addr); + sys_mmapper.warning("sys_mmapper_search_and_map(start_addr=0x%x, mem_id=0x%x, flags=0x%llx, alloc_addr=*0x%x)", start_addr, mem_id, flags, alloc_addr); const auto area = vm::get(vm::any, start_addr); @@ -303,11 +303,11 @@ error_code sys_mmapper_search_and_map(u32 start_addr, u32 mem_id, u64 flags, vm: error_code sys_mmapper_unmap_shared_memory(u32 addr, vm::ptr mem_id) { - sys_mmapper.error("sys_mmapper_unmap_shared_memory(addr=0x%x, mem_id=*0x%x)", addr, mem_id); + sys_mmapper.warning("sys_mmapper_unmap_shared_memory(addr=0x%x, mem_id=*0x%x)", addr, mem_id); const auto area = vm::get(vm::any, addr); - if (!area || addr != area->addr || addr < 0x30000000 || addr >= 0xC0000000) + if (!area || addr < 0x30000000 || addr >= 0xC0000000) { return CELL_EINVAL; } diff --git a/rpcs3/Emu/Cell/lv2/sys_vm.cpp b/rpcs3/Emu/Cell/lv2/sys_vm.cpp index 413c8927ea20..6acd966ea84e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_vm.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_vm.cpp @@ -10,7 +10,7 @@ error_code sys_vm_memory_map(u32 vsize, u32 psize, u32 cid, u64 flag, u64 policy { sys_vm.error("sys_vm_memory_map(vsize=0x%x, psize=0x%x, cid=0x%x, flags=0x%llx, policy=0x%llx, addr=*0x%x)", vsize, psize, cid, flag, policy, addr); - if (!vsize || !psize || vsize & 0x2000000 || vsize > 0x10000000 || psize > 0x10000000 || policy != SYS_VM_POLICY_AUTO_RECOMMENDED) + if (!vsize || !psize || vsize % 0x2000000 || vsize > 0x10000000 || psize > 0x10000000 || policy != SYS_VM_POLICY_AUTO_RECOMMENDED) { return CELL_EINVAL; } diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index b0cf8aec88ad..7e91eee08093 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -5,6 +5,7 @@ #include "Utilities/Thread.h" #include "Utilities/VirtualMemory.h" #include "Emu/CPU/CPUThread.h" +#include "Emu/Cell/lv2/sys_memory.h" #ifdef _WIN32 #include @@ -599,8 +600,17 @@ namespace vm { return 0; } + u8 pflags = page_readable | page_writable; + if ((flags & SYS_MEMORY_PAGE_SIZE_1M) == SYS_MEMORY_PAGE_SIZE_1M) + { + pflags |= page_1m_size; + } + else if ((flags & SYS_MEMORY_PAGE_SIZE_64K) == SYS_MEMORY_PAGE_SIZE_64K) + { + pflags |= page_64k_size; + } - if (!try_alloc(addr, size, page_readable | page_writable, sup)) + if (!try_alloc(addr, size, pflags, sup)) { return 0; }