diff --git a/src/gba/gba-savedata.c b/src/gba/gba-savedata.c index 3acb4cdc6..1c61c03dc 100644 --- a/src/gba/gba-savedata.c +++ b/src/gba/gba-savedata.c @@ -85,7 +85,7 @@ void GBASavedataInitFlash(struct GBASavedata* savedata) { if (end < SIZE_CART_FLASH512) { savedata->vf->truncate(savedata->vf, SIZE_CART_FLASH1M); } - savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_FLASH1M, MEMORY_WRITE); + savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_FLASH1M, MAP_WRITE); } savedata->currentBank = savedata->data; @@ -110,7 +110,7 @@ void GBASavedataInitEEPROM(struct GBASavedata* savedata) { if (end < SIZE_CART_EEPROM) { savedata->vf->truncate(savedata->vf, SIZE_CART_EEPROM); } - savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_EEPROM, MEMORY_WRITE); + savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_EEPROM, MAP_WRITE); } if (end < SIZE_CART_EEPROM) { memset(&savedata->data[end], 0xFF, SIZE_CART_EEPROM - end); @@ -133,7 +133,7 @@ void GBASavedataInitSRAM(struct GBASavedata* savedata) { if (end < SIZE_CART_SRAM) { savedata->vf->truncate(savedata->vf, SIZE_CART_SRAM); } - savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_SRAM, MEMORY_WRITE); + savedata->data = savedata->vf->map(savedata->vf, SIZE_CART_SRAM, MAP_WRITE); } if (end < SIZE_CART_SRAM) { diff --git a/src/gba/gba-serialize.c b/src/gba/gba-serialize.c index 9fa349cb8..62addac5a 100644 --- a/src/gba/gba-serialize.c +++ b/src/gba/gba-serialize.c @@ -99,7 +99,7 @@ bool GBALoadState(struct GBA* gba, int slot) { } struct GBASerializedState* GBAMapState(struct VFile* vf) { - return vf->map(vf, sizeof(struct GBASerializedState), MEMORY_WRITE); + return vf->map(vf, sizeof(struct GBASerializedState), MAP_WRITE); } void GBAUnmapState(struct VFile* vf, struct GBASerializedState* state) { diff --git a/src/gba/gba.c b/src/gba/gba.c index 79530b8d6..435ab5287 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -386,7 +386,7 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char gba->romVf = vf; gba->pristineRomSize = vf->seek(vf, 0, SEEK_END); vf->seek(vf, 0, SEEK_SET); - gba->pristineRom = vf->map(vf, SIZE_CART0, MEMORY_READ); + gba->pristineRom = vf->map(vf, SIZE_CART0, MAP_READ); gba->memory.rom = gba->pristineRom; gba->activeFile = fname; gba->memory.romSize = gba->pristineRomSize; @@ -398,7 +398,7 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char void GBALoadBIOS(struct GBA* gba, struct VFile* vf) { gba->biosVf = vf; - gba->memory.bios = vf->map(vf, SIZE_BIOS, MEMORY_READ); + gba->memory.bios = vf->map(vf, SIZE_BIOS, MAP_READ); gba->memory.fullBios = 1; uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS); GBALog(gba, GBA_LOG_DEBUG, "BIOS Checksum: 0x%X", checksum); diff --git a/src/util/memory.h b/src/util/memory.h index e9539ef1f..510049e8f 100644 --- a/src/util/memory.h +++ b/src/util/memory.h @@ -3,9 +3,6 @@ #include "common.h" -#define MEMORY_READ 1 -#define MEMORY_WRITE 2 - void* anonymousMemoryMap(size_t size); void mappedMemoryFree(void* memory, size_t size); diff --git a/src/util/vfs.c b/src/util/vfs.c index ce1457968..f536e164b 100644 --- a/src/util/vfs.c +++ b/src/util/vfs.c @@ -105,7 +105,7 @@ ssize_t _vfdWrite(struct VFile* vf, void* buffer, size_t size) { static void* _vfdMap(struct VFile* vf, size_t size, int flags) { struct VFileFD* vfd = (struct VFileFD*) vf; int mmapFlags = MAP_PRIVATE; - if (flags & MEMORY_WRITE) { + if (flags & MAP_WRITE) { mmapFlags = MAP_SHARED; } return mmap(0, size, PROT_READ | PROT_WRITE, mmapFlags, vfd->fd, 0); @@ -118,9 +118,9 @@ static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) { #else static void* _vfdMap(struct VFile* vf, size_t size, int flags) { struct VFileFD* vfd = (struct VFileFD*) vf; - int createFlags = PAGE_READONLY; - int mapFiles = FILE_MAP_READ; - if (flags & MEMORY_WRITE) { + int createFlags = PAGE_WRITECOPY; + int mapFiles = FILE_MAP_COPY; + if (flags & MAP_WRITE) { createFlags = PAGE_READWRITE; mapFiles = FILE_MAP_WRITE; } diff --git a/src/util/vfs.h b/src/util/vfs.h index c64f0a5eb..90cac8f19 100644 --- a/src/util/vfs.h +++ b/src/util/vfs.h @@ -3,7 +3,10 @@ #include "common.h" -#include "memory.h" +enum { + MAP_READ = 1, + MAP_WRITE = 2 +}; struct VFile { bool (*close)(struct VFile* vf);