Skip to content

Commit

Permalink
Merge pull request #1 from hrydgard/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Apology11 committed Feb 17, 2013
2 parents 9338cf9 + 8c80641 commit 289c252
Show file tree
Hide file tree
Showing 52 changed files with 3,568 additions and 435 deletions.
23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ if(ANDROID)
endif()

if (IOS)
if (${IOS_PLATFORM} STREQUAL "OS")
set(ARM ON)
endif()
set(ARM ON)
endif()

if(BLACKBERRY)
Expand Down Expand Up @@ -410,6 +408,16 @@ if(ANDROID)
native/android/native-audio-so.h)
target_link_libraries(native_audio OpenSLES)
# No target
elseif(IOS)
set(nativeExtra ${nativeExtra}
ios/main.m
ios/AppDelegate.m
ios/AppDelegate.h
ios/ViewController.mm
ios/ViewController.h)
set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit")
# No target
# set(TargetBin PPSSPP)
elseif(USING_QT_UI)
# Currently unused
find_package(Qt4 COMPONENTS QtMultimedia QtOpenGL QtGui QtCore)
Expand All @@ -433,9 +441,7 @@ elseif(SDL_FOUND)
elseif(PANDORA)
set(nativeExtraLibs ${nativeExtraLibs} pthread EGL X11)
endif()
if(NOT IOS) # No target
set(TargetBin PPSSPPSDL)
endif()
set(TargetBin PPSSPPSDL)
else()
message(FATAL_ERROR "Could not find SDL. Failing.")
endif()
Expand Down Expand Up @@ -950,4 +956,9 @@ endif()

file(INSTALL ${NativeAssets} DESTINATION assets)

# code signing
if (IOS)
set_target_properties(${NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST PPSSPP-Info.plist XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: My Name")
endif()

#include(CPack)
54 changes: 29 additions & 25 deletions Common/MemArena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ void MemArena::GrabLowMemSpace(size_t size)
ERROR_LOG(MEMMAP, "Failed to grab ashmem space of size: %08x errno: %d", (int)size, (int)(errno));
return;
}
#elif defined(UNUSABLE_MMAP)
// Do nothing as we are using malloc()
#else
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
fd = open(ram_temp_file.c_str(), O_RDWR | O_CREAT, mode);
Expand All @@ -157,8 +155,9 @@ void MemArena::ReleaseSpace()
#ifdef _WIN32
CloseHandle(hMemoryMapping);
hMemoryMapping = 0;
#elif defined(UNUSABLE_MMAP)
// Do nothing as we are using malloc()
#elif defined(__SYMBIAN32__)
memmap->Close();
delete memmap;
#else
close(fd);
#endif
Expand All @@ -170,20 +169,7 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base)
#ifdef _WIN32
size = roundup(size);
void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
if (!ptr) {
//ERROR_LOG(MEMMAP, "Failed to map memory: %08x %08x %08x : %s", (u32)offset, (u32)size, (u32)base, GetLastErrorMsg());
} else {
//ERROR_LOG(MEMMAP, "Mapped memory: %08x %08x %08x : %s", (u32)offset, (u32)size, (u32)base, GetLastErrorMsg());
}
return ptr;
#elif defined(UNUSABLE_MMAP)
void *retval = malloc(size);
if (!retval)
{
NOTICE_LOG(MEMMAP, "malloc failed: %s", strerror(errno));
return 0;
}
return retval;
#else
void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
((base == 0) ? 0 : MAP_FIXED), fd, offset);
Expand All @@ -202,14 +188,14 @@ void MemArena::ReleaseView(void* view, size_t size)
{
#ifdef _WIN32
UnmapViewOfFile(view);
#elif defined(UNUSABLE_MMAP)
free(view);
#elif defined(__SYMBIAN32__)
memmap->Decommit(((int)view - (int)memmap->Base()) & 0x3FFFFFFF, size);
#else
munmap(view, size);
#endif
}


#ifndef __SYMBIAN32__
u8* MemArena::Find4GBBase()
{
#ifdef _M_X64
Expand All @@ -224,18 +210,15 @@ u8* MemArena::Find4GBBase()
return reinterpret_cast<u8*>(0x2300000000ULL);
#endif

#else
// 32 bit
#else // 32 bit

#ifdef _WIN32
// The highest thing in any 1GB section of memory space is the locked cache. We only need to fit it.
u8* base = (u8*)VirtualAlloc(0, 0x10000000, MEM_RESERVE, PAGE_READWRITE);
if (base) {
VirtualFree(base, 0, MEM_RELEASE);
}
return base;
#elif defined(UNUSABLE_MMAP)
// We are unable to use relative addresses due to lack of mmap()
return NULL;
#else
void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED, -1, 0);
Expand All @@ -248,6 +231,7 @@ u8* MemArena::Find4GBBase()
#endif
#endif
}
#endif


// yeah, this could also be done in like two bitwise ops...
Expand Down Expand Up @@ -282,6 +266,12 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
if (view.flags & MV_MIRROR_PREVIOUS) {
position = last_position;
} else {
#ifdef __SYMBIAN32__
*(view.out_ptr_low) = (u8*)((int)arena->memmap->Base() + view.virtual_address);
arena->memmap->Commit(view.virtual_address & 0x3FFFFFFF, view.size);
}
*(view.out_ptr) = (u8*)((int)arena->memmap->Base() + view.virtual_address & 0x3FFFFFFF);
#else
*(view.out_ptr_low) = (u8*)arena->CreateView(position, view.size);
if (!*view.out_ptr_low)
goto bail;
Expand All @@ -299,6 +289,8 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
if (!*view.out_ptr)
goto bail;
}
#endif

#endif
last_position = position;
position += roundup(view.size);
Expand Down Expand Up @@ -344,7 +336,9 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
total_mem += roundup(views[i].size);
}
// Grab some pagefile backed memory out of the void ...
#ifndef __SYMBIAN32__
arena->GrabLowMemSpace(total_mem);
#endif

// Now, create views in high memory where there's plenty of space.
#ifdef _M_X64
Expand Down Expand Up @@ -374,6 +368,16 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
break;
}
}
#elif defined(__SYMBIAN32__)
arena->memmap = new RChunk();
arena->memmap->CreateDisconnectedLocal(0 , 0, 0x10000000);
if (!Memory_TryBase(arena->memmap->Base(), views, num_views, flags, arena))
{
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
exit(0);
return 0;
}
u8* base = arena->memmap->Base();
#else
// Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
u8 *base = MemArena::Find4GBBase();
Expand Down
8 changes: 8 additions & 0 deletions Common/MemArena.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <windows.h>
#endif

#ifdef __SYMBIAN32__
#include <e32std.h>
#endif

#include "Common.h"

// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
Expand All @@ -36,8 +40,12 @@ class MemArena
void *CreateView(s64 offset, size_t size, void *base = 0);
void ReleaseView(void *view, size_t size);

#ifdef __SYMBIAN32__
RChunk* memmap;
#else
// This only finds 1 GB in 32-bit
static u8 *Find4GBBase();
#endif
private:

#ifdef _WIN32
Expand Down
5 changes: 0 additions & 5 deletions Common/MemoryUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#endif
#include <string>

#if defined(__SYMBIAN32__)
// Also Xbox 360
#define UNUSABLE_MMAP 1
#endif

void* AllocateExecutableMemory(size_t size, bool low = true);
void* AllocateMemoryPages(size_t size);
void FreeMemoryPages(void* ptr, size_t size);
Expand Down
2 changes: 2 additions & 0 deletions Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void Core_Run()
case CORE_STEPPING:
//1: wait for step command..
#if defined(USING_QT_UI) || defined(_DEBUG)
host->UpdateDisassembly();
host->UpdateMemView();
host->SendCoreWait(true);
#endif

Expand Down
Loading

0 comments on commit 289c252

Please sign in to comment.