mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Use the mach memory functions on Mac and 32-bit iOS as well.
This commit is contained in:
parent
98e0ccf1e1
commit
b9bbee5c85
7 changed files with 39 additions and 19 deletions
|
@ -97,6 +97,7 @@ public:
|
||||||
|
|
||||||
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
||||||
void FreeCodeSpace() {
|
void FreeCodeSpace() {
|
||||||
|
ProtectMemoryPages(region, region_size, MEM_PROT_READ | MEM_PROT_WRITE);
|
||||||
FreeMemoryPages(region, region_size);
|
FreeMemoryPages(region, region_size);
|
||||||
region = nullptr;
|
region = nullptr;
|
||||||
region_size = 0;
|
region_size = 0;
|
||||||
|
|
|
@ -295,6 +295,7 @@
|
||||||
<ClCompile Include="MemArenaAndroid.cpp" />
|
<ClCompile Include="MemArenaAndroid.cpp" />
|
||||||
<ClCompile Include="MemArenaPosix.cpp" />
|
<ClCompile Include="MemArenaPosix.cpp" />
|
||||||
<ClCompile Include="MemArenaWin32.cpp" />
|
<ClCompile Include="MemArenaWin32.cpp" />
|
||||||
|
<ClCompile Include="MemArenaDarwin.cpp" />
|
||||||
<ClCompile Include="MemoryUtil.cpp" />
|
<ClCompile Include="MemoryUtil.cpp" />
|
||||||
<ClCompile Include="MipsEmitter.cpp" />
|
<ClCompile Include="MipsEmitter.cpp" />
|
||||||
<ClCompile Include="Misc.cpp" />
|
<ClCompile Include="Misc.cpp" />
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
<ClCompile Include="MemArenaPosix.cpp" />
|
<ClCompile Include="MemArenaPosix.cpp" />
|
||||||
<ClCompile Include="MemArenaWin32.cpp" />
|
<ClCompile Include="MemArenaWin32.cpp" />
|
||||||
<ClCompile Include="MemArenaAndroid.cpp" />
|
<ClCompile Include="MemArenaAndroid.cpp" />
|
||||||
|
<ClCompile Include="MemArenaDarwin.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Crypto">
|
<Filter Include="Crypto">
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "CommonWindows.h"
|
#include "CommonWindows.h"
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <mach/mach.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
@ -47,9 +49,9 @@ private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hMemoryMapping;
|
HANDLE hMemoryMapping;
|
||||||
SYSTEM_INFO sysInfo;
|
SYSTEM_INFO sysInfo;
|
||||||
#elif defined(IOS) && PPSSPP_ARCH(ARM64)
|
#elif defined(__APPLE__)
|
||||||
size_t vm_size;
|
size_t vm_size;
|
||||||
uintptr_t vm_mem; // same type as vm_address_t
|
vm_address_t vm_mem; // same type as vm_address_t
|
||||||
#else
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "ppsspp_config.h"
|
#include "ppsspp_config.h"
|
||||||
|
|
||||||
#if defined(IOS) && PPSSPP_ARCH(ARM64)
|
#if defined(__APPLE__)
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -39,8 +39,7 @@ size_t MemArena::roundup(size_t x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemArena::GrabLowMemSpace(size_t size)
|
void MemArena::GrabLowMemSpace(size_t size) {
|
||||||
{
|
|
||||||
vm_size = size;
|
vm_size = size;
|
||||||
kern_return_t retval = vm_allocate(mach_task_self(), &vm_mem, size, VM_FLAGS_ANYWHERE);
|
kern_return_t retval = vm_allocate(mach_task_self(), &vm_mem, size, VM_FLAGS_ANYWHERE);
|
||||||
if (retval != KERN_SUCCESS) {
|
if (retval != KERN_SUCCESS) {
|
||||||
|
@ -56,8 +55,7 @@ void MemArena::ReleaseSpace() {
|
||||||
vm_mem = 0;
|
vm_mem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
void *MemArena::CreateView(s64 offset, size_t size, void *base) {
|
||||||
{
|
|
||||||
mach_port_t self = mach_task_self();
|
mach_port_t self = mach_task_self();
|
||||||
vm_address_t target = (vm_address_t)base;
|
vm_address_t target = (vm_address_t)base;
|
||||||
uint64_t mask = 0;
|
uint64_t mask = 0;
|
||||||
|
@ -86,12 +84,34 @@ void MemArena::ReleaseView(void* view, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MemArena::NeedsProbing() {
|
bool MemArena::NeedsProbing() {
|
||||||
|
#if defined(IOS) && PPSSPP_ARCH(64BIT)
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* MemArena::Find4GBBase() {
|
u8* MemArena::Find4GBBase() {
|
||||||
|
#if defined(IOS) && PPSSPP_ARCH(64BIT)
|
||||||
// The caller will need to do probing, like on 32-bit Windows.
|
// The caller will need to do probing, like on 32-bit Windows.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
#else
|
||||||
|
size_t size;
|
||||||
|
#if PPSSPP_ARCH(64BIT)
|
||||||
|
size = 0xE1000000;
|
||||||
|
#else
|
||||||
|
size = 0x10000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vm_address_t addr = 0;
|
||||||
|
kern_return_t retval = vm_allocate(mach_task_self(), &addr, size, VM_FLAGS_ANYWHERE);
|
||||||
|
if (retval == KERN_SUCCESS) {
|
||||||
|
// Don't need the memory now, was just probing.
|
||||||
|
vm_deallocate(mach_task_self(), addr, size);
|
||||||
|
return (u8 *)addr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // defined(IOS) && PPSSPP_ARCH(ARM64)
|
#endif // __APPLE__
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "ppsspp_config.h"
|
#include "ppsspp_config.h"
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(ANDROID) && !(defined(IOS) && PPSSPP_ARCH(ARM64))
|
#if !defined(_WIN32) && !defined(ANDROID) && !defined(__APPLE__)
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -107,13 +107,14 @@ u8* MemArena::Find4GBBase() {
|
||||||
// This makes the Windows approach above unusable on Linux, so we will simply pray...
|
// This makes the Windows approach above unusable on Linux, so we will simply pray...
|
||||||
return reinterpret_cast<u8*>(0x2300000000ULL);
|
return reinterpret_cast<u8*>(0x2300000000ULL);
|
||||||
#else
|
#else
|
||||||
void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE,
|
size_t size = 0x10000000;
|
||||||
|
void* base = mmap(0, size, PROT_READ | PROT_WRITE,
|
||||||
MAP_ANON | MAP_SHARED, -1, 0);
|
MAP_ANON | MAP_SHARED, -1, 0);
|
||||||
if (base == MAP_FAILED) {
|
if (base == MAP_FAILED) {
|
||||||
PanicAlert("Failed to map 256 MB of memory space: %s", strerror(errno));
|
PanicAlert("Failed to map 256 MB of memory space: %s", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
munmap(base, 0x10000000);
|
munmap(base, size);
|
||||||
return static_cast<u8*>(base);
|
return static_cast<u8*>(base);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ bool simulateAnalog = false;
|
||||||
extern ScreenManager *screenManager;
|
extern ScreenManager *screenManager;
|
||||||
InputState input_state;
|
InputState input_state;
|
||||||
|
|
||||||
extern std::string ram_temp_file;
|
|
||||||
extern bool iosCanUseJit;
|
extern bool iosCanUseJit;
|
||||||
extern bool targetIsJailbroken;
|
extern bool targetIsJailbroken;
|
||||||
|
|
||||||
|
@ -97,11 +96,6 @@ static GraphicsContext *graphicsContext;
|
||||||
|
|
||||||
net::Init();
|
net::Init();
|
||||||
|
|
||||||
#if defined(IOS) && PPSSPP_ARCH(ARM64)
|
|
||||||
#else
|
|
||||||
ram_temp_file = [[NSTemporaryDirectory() stringByAppendingPathComponent:@"ram_tmp.file"] fileSystemRepresentation];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iosCanUseJit = true;
|
iosCanUseJit = true;
|
||||||
targetIsJailbroken = false;
|
targetIsJailbroken = false;
|
||||||
NSArray *jailPath = [NSArray arrayWithObjects:
|
NSArray *jailPath = [NSArray arrayWithObjects:
|
||||||
|
|
Loading…
Add table
Reference in a new issue