#ifdef __linux__
void *tmp;
- tmp = mmap(tcache, DRC_TCACHE_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
+ tmp = mmap(tcache, DRC_TCACHE_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
printf("mmap tcache: %p, asked %p\n", tmp, tcache);
#endif
}
return 0;\r
}\r
\r
+int PicoCartResize(int newsize)\r
+{\r
+ void *tmp = plat_mremap(Pico.rom, rom_alloc_size, newsize);\r
+ if (tmp == NULL)\r
+ return -1;\r
+\r
+ Pico.rom = tmp;\r
+ rom_alloc_size = newsize;\r
+ return 0;\r
+}\r
+\r
void PicoCartUnload(void)\r
{\r
if (PicoCartUnloadHook != NULL) {\r
void carthw_realtec_startup(void)
{
- void *tmp;
int i;
elprintf(EL_STATUS, "Realtec mapper startup");
// allocate additional bank for boot code
// (we know those ROMs have aligned size)
- tmp = realloc(Pico.rom, Pico.romsize + M68K_BANK_SIZE);
- if (tmp == NULL)
- {
+ i = PicoCartResize(Pico.romsize + M68K_BANK_SIZE);
+ if (i != 0) {
elprintf(EL_STATUS, "OOM");
return;
}
- Pico.rom = tmp;
// create bank for boot code
for (i = 0; i < M68K_BANK_SIZE; i += 0x2000)
void carthw_prot_lk3_startup(void)
{
- void *tmp;
+ int ret;
elprintf(EL_STATUS, "lk3 prot emu startup");
// allocate space for bank0 backup
- tmp = realloc(Pico.rom, Pico.romsize + 0x8000);
- if (tmp == NULL)
- {
+ ret = PicoCartResize(Pico.romsize + 0x8000);
+ if (ret != 0) {
elprintf(EL_STATUS, "OOM");
return;
}
- Pico.rom = tmp;
memcpy(Pico.rom + Pico.romsize, Pico.rom, 0x8000);
PicoCartMemSetup = carthw_prot_lk3_mem_setup;
void PicoSVPStartup(void)
{
- void *tmp;
+ int ret;
elprintf(EL_STATUS, "SVP startup");
- tmp = realloc(Pico.rom, 0x200000 + sizeof(*svp));
- if (tmp == NULL)
- {
+ ret = PicoCartResize(Pico.romsize + sizeof(*svp));
+ if (ret != 0) {
elprintf(EL_STATUS|EL_SVP, "OOM for SVP data");
return;
}
- //PicoOpt &= ~0x20000;
- Pico.rom = tmp;
- svp = (void *) ((char *)tmp + 0x200000);
+ svp = (void *) ((char *)Pico.rom + Pico.romsize);
memset(svp, 0, sizeof(*svp));
// init SVP compiler
PicoAHW |= PAHW_SVP;
}
-
static int SekUnrecognizedOpcodeS68k(void)
{
- unsigned int pc, op;
- pc = SekPcS68k;
- op = PicoCpuCS68k.read16(pc);
- elprintf(EL_ANOMALY, "Unrecognized Opcode %04x @ %06x", op, pc);
+ elprintf(EL_ANOMALY, "Unrecognized Opcode @ %06x", SekPcS68k);
//exit(1);
return 0;
}
+#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <dirent.h>
void *plat_mmap(unsigned long addr, size_t size)
{
void *req, *ret;
+
req = (void *)addr;
- ret = mmap(req, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
+ ret = mmap(req, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (ret == MAP_FAILED)
return NULL;
if (ret != req)
return ret;
}
+void *plat_mremap(void *ptr, size_t oldsize, size_t newsize)
+{
+ void *ret;
+
+ ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE);
+ if (ret == MAP_FAILED)
+ return NULL;
+ if (ret != ptr)
+ printf("warning: mremap moved: %p -> %p\n", ptr, ret);
+
+ return ret;
+}
+
void plat_munmap(void *ptr, size_t size)
{
munmap(ptr, size);