This commit is contained in:
Nekotekina 2014-08-31 13:54:12 +04:00
parent 26e03fa794
commit 571bd63644
7 changed files with 313 additions and 211 deletions

View file

@ -6,14 +6,14 @@
#ifndef _WIN32
#include <sys/mman.h>
#else
#include <Windows.h>
#endif
/* OS X uses MAP_ANON instead of MAP_ANONYMOUS */
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
#else
#include <Windows.h>
#endif
MemoryBase Memory;
@ -108,14 +108,11 @@ void MemoryBase::Init(MemoryType type)
memset(RawSPUMem, 0, sizeof(RawSPUMem));
#ifdef _WIN32
m_base_addr = VirtualAlloc(nullptr, 0x100000000, MEM_RESERVE, PAGE_NOACCESS);
if (!m_base_addr)
#else
m_base_addr = ::mmap(nullptr, 0x100000000, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (m_base_addr == (void*)-1)
if ((s64)m_base_addr == (s64)-1)
#endif
{
m_base_addr = nullptr;
LOG_ERROR(MEMORY, "Initializing memory failed");
assert(0);
return;
@ -139,7 +136,6 @@ void MemoryBase::Init(MemoryType type)
case Memory_PSV:
MemoryBlocks.push_back(PSV.RAM.SetRange(0x81000000, 0x10000000));
MemoryBlocks.push_back(UserMemory = PSV.Userspace.SetRange(0x91000000, 0x10000000));
PSV.Init(GetBaseAddr());
break;
case Memory_PSP:
@ -148,7 +144,6 @@ void MemoryBase::Init(MemoryType type)
MemoryBlocks.push_back(PSP.RAM.SetRange(0x08000000, 0x02000000));
MemoryBlocks.push_back(PSP.Kernel.SetRange(0x88000000, 0x00800000));
MemoryBlocks.push_back(UserMemory = PSP.Userspace.SetRange(0x08800000, 0x01800000));
PSP.Init(GetBaseAddr());
break;
}
@ -173,17 +168,17 @@ void MemoryBase::Close()
MemoryBlocks.clear();
#ifdef _WIN32
if (!VirtualFree(m_base_addr, 0, MEM_RELEASE))
{
LOG_ERROR(MEMORY, "VirtualFree(0x%llx) failed", (u64)m_base_addr);
}
#else
if (::munmap(m_base_addr, 0x100000000))
{
LOG_ERROR(MEMORY, "::munmap(0x%llx) failed", (u64)m_base_addr);
}
#endif
//#ifdef _WIN32
// if (!VirtualFree(m_base_addr, 0, MEM_RELEASE))
// {
// LOG_ERROR(MEMORY, "VirtualFree(0x%llx) failed", (u64)m_base_addr);
// }
//#else
// if (::munmap(m_base_addr, 0x100000000))
// {
// LOG_ERROR(MEMORY, "::munmap(0x%llx) failed", (u64)m_base_addr);
// }
//#endif
}
void MemoryBase::WriteMMIO32(u32 addr, const u32 data)