diff options
Diffstat (limited to 'libpcsxcore')
-rw-r--r-- | libpcsxcore/cdriso.c | 3 | ||||
-rw-r--r-- | libpcsxcore/new_dynarec/new_dynarec.c | 32 | ||||
-rw-r--r-- | libpcsxcore/psxmem.c | 14 |
3 files changed, 40 insertions, 9 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index bfa7d76..d6672f9 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -34,6 +34,7 @@ #include <sys/time.h> #include <unistd.h> #endif +#include <errno.h> #include <zlib.h> unsigned int cdrIsoMultidiskCount; @@ -1222,6 +1223,8 @@ static long CALLBACK ISOopen(void) { cdHandle = fopen(GetIsoFile(), "rb"); if (cdHandle == NULL) { + SysPrintf(_("Could't open '%s' for reading: %s\n"), + GetIsoFile(), strerror(errno)); return -1; } diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 8437008..d8d8991 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <stdint.h> //include for uint64_t #include <assert.h> +#include <errno.h> #include <sys/mman.h> #include "emu_if.h" //emulator interface @@ -8005,6 +8006,28 @@ void disassemble_inst(int i) static void disassemble_inst(int i) {} #endif // DISASM +#define DRC_TEST_VAL 0x74657374 + +static int new_dynarec_test(void) +{ + int (*testfunc)(void) = (void *)out; + int ret; + emit_movimm(DRC_TEST_VAL,0); // test + emit_jmpreg(14); + literal_pool(0); +#ifdef __arm__ + __clear_cache((void *)testfunc, out); +#endif + SysPrintf("testing if we can run recompiled code..\n"); + ret = testfunc(); + if (ret == DRC_TEST_VAL) + SysPrintf("test passed.\n"); + else + SysPrintf("test failed: %08x\n", ret); + out=(u_char *)BASE_ADDR; + return ret == DRC_TEST_VAL; +} + // clear the state completely, instead of just marking // things invalid like invalidate_all_pages() does void new_dynarec_clear_full() @@ -8039,17 +8062,19 @@ void new_dynarec_clear_full() void new_dynarec_init() { - printf("Init new dynarec\n"); + SysPrintf("Init new dynarec\n"); out=(u_char *)BASE_ADDR; #if BASE_ADDR_FIXED if (mmap (out, 1<<TARGET_SIZE_2, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0) <= 0) {SysPrintf("mmap() failed\n");} + -1, 0) <= 0) { + SysPrintf("mmap() failed: %s\n", strerror(errno)); + } #else // not all systems allow execute in data segment by default if (mprotect(out, 1<<TARGET_SIZE_2, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) - SysPrintf("mprotect() failed\n"); + SysPrintf("mprotect() failed: %s\n", strerror(errno)); #endif #ifdef MUPEN64 rdword=&readmem_dword; @@ -8104,6 +8129,7 @@ void new_dynarec_init() #endif tlb_hacks(); arch_init(); + new_dynarec_test(); #ifndef RAM_FIXED ram_offset=(u_int)rdram-0x80000000; #endif diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 4da0cf4..2ca5dd5 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -95,7 +95,8 @@ void psxUnmap(void *ptr, size_t size, enum psxMapTag tag) return; } - munmap(ptr, size); + if (ptr) + munmap(ptr, size); } s8 *psxM = NULL; // Kernel & User Memory (2 Meg) @@ -155,6 +156,7 @@ int psxMemInit() { if (psxMemRLUT == NULL || psxMemWLUT == NULL || psxR == NULL || psxP == NULL || psxH != (void *)0x1f800000) { SysMessage(_("Error allocating memory!")); + psxMemShutdown(); return -1; } @@ -208,12 +210,12 @@ void psxMemReset() { } void psxMemShutdown() { - psxUnmap(psxM, 0x00210000, MAP_TAG_RAM); - psxUnmap(psxH, 0x10000, MAP_TAG_OTHER); - psxUnmap(psxR, 0x80000, MAP_TAG_OTHER); + psxUnmap(psxM, 0x00210000, MAP_TAG_RAM); psxM = NULL; + psxUnmap(psxH, 0x10000, MAP_TAG_OTHER); psxH = NULL; + psxUnmap(psxR, 0x80000, MAP_TAG_OTHER); psxR = NULL; - free(psxMemRLUT); - free(psxMemWLUT); + free(psxMemRLUT); psxMemRLUT = NULL; + free(psxMemWLUT); psxMemWLUT = NULL; } static int writeok = 1; |