Skip to content

Commit

Permalink
Mmapper with Neko's review fixes (#2503)
Browse files Browse the repository at this point in the history
  • Loading branch information
Inviuz authored and Nekotekina committed Mar 12, 2017
1 parent 14e5aa5 commit b70a1ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 5 additions & 5 deletions rpcs3/Emu/Cell/lv2/sys_mmapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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<u32> 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);

Expand Down Expand Up @@ -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<u32> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/lv2/sys_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 11 additions & 1 deletion rpcs3/Emu/Memory/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Windows.h>
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b70a1ed

Please sign in to comment.