Mirror writable aica ram to 8mb in 512mb vmem mode

Fixes switching from dc to naomi on windows
Should help games reading past end of aica ram (HeadHunter and others)
This commit is contained in:
Flyinghead 2019-07-10 20:17:59 +02:00
parent ad98e583c8
commit 5285911133
4 changed files with 13 additions and 27 deletions

View File

@ -547,10 +547,6 @@ static void _vmem_term_mappings()
aica_ram.data = NULL;
}
}
else
{
vmem_platform_delete_mappings();
}
}
void _vmem_init_mappings()
@ -583,7 +579,6 @@ void _vmem_init_mappings()
const vmem_mapping mem_mappings[] = {
{0x00000000, 0x00800000, 0, 0, false}, // Area 0 -> unused
{0x00800000, 0x01000000, MAP_ARAM_START_OFFSET, ARAM_SIZE, false}, // Aica
{0x20000000, 0x20000000+ARAM_SIZE, MAP_ARAM_START_OFFSET, ARAM_SIZE, true},
{0x01000000, 0x04000000, 0, 0, false}, // More unused
{0x04000000, 0x05000000, MAP_VRAM_START_OFFSET, VRAM_SIZE, true}, // Area 1 (vram, 16MB, wrapped on DC as 2x8MB)
{0x05000000, 0x06000000, 0, 0, false}, // 32 bit path (unused)
@ -592,6 +587,8 @@ void _vmem_init_mappings()
{0x08000000, 0x0C000000, 0, 0, false}, // Area 2
{0x0C000000, 0x10000000, MAP_RAM_START_OFFSET, RAM_SIZE, true}, // Area 3 (main RAM + 3 mirrors)
{0x10000000, 0x20000000, 0, 0, false}, // Area 4-7 (unused)
// This is outside of the 512MB addr space
{0x20000000, 0x20800000, MAP_ARAM_START_OFFSET, ARAM_SIZE, true}, // writable aica ram
};
vmem_platform_create_mappings(&mem_mappings[0], ARRAY_SIZE(mem_mappings));

View File

@ -22,8 +22,6 @@ void vmem_platform_reset_mem(void *ptr, unsigned size_bytes);
void vmem_platform_ondemand_page(void *address, unsigned size_bytes);
// To create the mappings in the address space.
void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned nummaps);
// Delete (unmap) the previously mapped regions
void vmem_platform_delete_mappings();
// Just tries to wipe as much as possible in the relevant area.
void vmem_platform_destroy();
// Given a block of data in the .text section, prepares it for JIT action.

View File

@ -235,14 +235,6 @@ void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned numma
}
}
void vmem_platform_delete_mappings()
{
if (vmem_4gb_space)
vmem_platform_reset_mem(virt_ram_base, 0x100000000);
else
vmem_platform_reset_mem(virt_ram_base, 0x20000000);
}
// Prepares the code region for JIT operations, thus marking it as RWX
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rwx) {
// Try to map is as RWX, this fails apparently on OSX (and perhaps other systems?)

View File

@ -66,7 +66,11 @@ static std::vector<void *> mapped_regions;
// Plase read the POSIX implementation for more information. On Windows this is
// rather straightforward.
VMemType vmem_platform_init(void **vmem_base_addr, void **sh4rcb_addr) {
VMemType vmem_platform_init(void **vmem_base_addr, void **sh4rcb_addr)
{
unmapped_regions.reserve(32);
mapped_regions.reserve(32);
// Firt let's try to allocate the in-memory file
mem_handle = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, RAM_SIZE_MAX + VRAM_SIZE_MAX + ARAM_SIZE_MAX, 0);
@ -116,7 +120,12 @@ void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned numma
// we unmap the whole thing only to remap it later.
// Unmap the whole section
vmem_platform_delete_mappings();
for (void *p : mapped_regions)
mem_region_unmap_file(p, 0);
mapped_regions.clear();
for (void *p : unmapped_regions)
mem_region_release(p, 0);
unmapped_regions.clear();
for (unsigned i = 0; i < nummaps; i++) {
unsigned address_range_size = vmem_maps[i].end_address - vmem_maps[i].start_address;
@ -146,16 +155,6 @@ void vmem_platform_create_mappings(const vmem_mapping *vmem_maps, unsigned numma
}
}
void vmem_platform_delete_mappings()
{
for (void *p : mapped_regions)
mem_region_unmap_file(p, 0);
mapped_regions.clear();
for (void *p : unmapped_regions)
mem_region_release(p, 0);
unmapped_regions.clear();
}
typedef void* (*mapper_fn) (void *addr, unsigned size);
// This is a tempalted function since it's used twice