aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotaz2012-08-21 02:04:46 +0300
committernotaz2012-10-12 00:05:08 +0300
commita2ad8cc5a68892c8ae7d1964f4081f755654d325 (patch)
tree32c7ac445e6b999530489ba2b6895472b08ca54a
parent9ee0fd5b333039b1140d90f935aa9299825f1e42 (diff)
downloadpcsx_rearmed-a2ad8cc5a68892c8ae7d1964f4081f755654d325.tar.gz
pcsx_rearmed-a2ad8cc5a68892c8ae7d1964f4081f755654d325.tar.bz2
pcsx_rearmed-a2ad8cc5a68892c8ae7d1964f4081f755654d325.zip
use plat_mmap for RAM too
-rw-r--r--frontend/common/plat.h2
-rw-r--r--frontend/linux/plat.c4
-rw-r--r--frontend/plugin_lib.c2
-rw-r--r--libpcsxcore/psxmem.c15
4 files changed, 17 insertions, 6 deletions
diff --git a/frontend/common/plat.h b/frontend/common/plat.h
index 416f8ac..1fb8767 100644
--- a/frontend/common/plat.h
+++ b/frontend/common/plat.h
@@ -45,7 +45,7 @@ int plat_is_dir(const char *path);
int plat_wait_event(int *fds_hnds, int count, int timeout_ms);
void plat_sleep_ms(int ms);
-void *plat_mmap(unsigned long addr, size_t size, int need_exec);
+void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);
void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);
void plat_munmap(void *ptr, size_t size);
diff --git a/frontend/linux/plat.c b/frontend/linux/plat.c
index 044084e..4ed1e65 100644
--- a/frontend/linux/plat.c
+++ b/frontend/linux/plat.c
@@ -134,7 +134,7 @@ int plat_wait_event(int *fds_hnds, int count, int timeout_ms)
return ret;
}
-void *plat_mmap(unsigned long addr, size_t size, int need_exec)
+void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed)
{
static int hugetlb_disabled;
int prot = PROT_READ | PROT_WRITE;
@@ -144,6 +144,8 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec)
req = (void *)addr;
if (need_exec)
prot |= PROT_EXEC;
+ if (is_fixed)
+ flags |= MAP_FIXED;
if (size >= HUGETLB_THRESHOLD && !hugetlb_disabled)
flags |= MAP_HUGETLB;
diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c
index c2e2ab4..484d67b 100644
--- a/frontend/plugin_lib.c
+++ b/frontend/plugin_lib.c
@@ -487,7 +487,7 @@ static void pl_get_layer_pos(int *x, int *y, int *w, int *h)
static void *pl_mmap(unsigned int size)
{
- return plat_mmap(0, size, 0);
+ return plat_mmap(0, size, 0, 0);
}
static void pl_munmap(void *ptr, unsigned int size)
diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c
index 1cabd53..ddcd05b 100644
--- a/libpcsxcore/psxmem.c
+++ b/libpcsxcore/psxmem.c
@@ -60,6 +60,16 @@ u8 **psxMemRLUT = NULL;
0xbfc0_0000-0xbfc7_ffff BIOS Mirror (512K) Uncached
*/
+#if 1
+void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);
+void plat_munmap(void *ptr, size_t size);
+#else
+#define plat_mmap(addr, size, need_exec, is_fixed) \
+ mmap((void *)addr, size, PROT_WRITE | PROT_READ, \
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0)
+#define plat_munmap munmap
+#endif
+
int psxMemInit() {
int i;
@@ -68,8 +78,7 @@ int psxMemInit() {
memset(psxMemRLUT, 0, 0x10000 * sizeof(void *));
memset(psxMemWLUT, 0, 0x10000 * sizeof(void *));
- psxM = mmap((void *)0x80000000, 0x00210000,
- PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+ psxM = plat_mmap(0x80000000, 0x00210000, 0, 1);
#ifndef RAM_FIXED
if (psxM == MAP_FAILED)
psxM = mmap((void *)0x70000000, 0x00210000,
@@ -144,7 +153,7 @@ void psxMemReset() {
}
void psxMemShutdown() {
- munmap(psxM, 0x00210000);
+ plat_munmap(psxM, 0x00210000);
munmap(psxH, 0x1f800000);
munmap(psxR, 0x80000);