ALi M6117-related memory and ROM fixes.

This commit is contained in:
OBattler
2022-07-18 23:48:18 +02:00
parent 69d0ff454c
commit 25783f137d
3 changed files with 50 additions and 21 deletions

View File

@@ -1319,7 +1319,6 @@ writememll(uint32_t addr, uint32_t val)
uint32_t
readmemll_no_mmut(uint32_t addr, uint32_t *a64)
{
#ifndef NO_MMUT
mem_mapping_t *map;
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_READ, 4);
@@ -1367,9 +1366,6 @@ readmemll_no_mmut(uint32_t addr, uint32_t *a64)
((uint32_t) (map->read_b(addr + 3, map->p)) << 24);
return 0xffffffff;
#else
return readmemll(addr);
#endif
}
@@ -1377,7 +1373,6 @@ readmemll_no_mmut(uint32_t addr, uint32_t *a64)
void
writememll_no_mmut(uint32_t addr, uint32_t *a64, uint32_t val)
{
#ifndef NO_MMUT
mem_mapping_t *map;
GDBSTUB_MEM_ACCESS(addr, GDBSTUB_MEM_WRITE, 4);
@@ -1435,9 +1430,6 @@ writememll_no_mmut(uint32_t addr, uint32_t *a64, uint32_t val)
map->write_b(addr + 3, val >> 24, map->p);
return;
}
#else
writememll(addr, val);
#endif
}
@@ -1668,7 +1660,7 @@ mem_readb_phys(uint32_t addr)
if (map) {
if (map->exec)
ret = map->exec[addr - map->base];
ret = map->exec[(addr - map->base) & map->mask];
else if (map->read_b)
ret = map->read_b(addr, map->p);
}
@@ -1686,7 +1678,7 @@ mem_readw_phys(uint32_t addr)
mem_logical_addr = 0xffffffff;
if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (map && map->exec)) {
p = (uint16_t *) &(map->exec[addr - map->base]);
p = (uint16_t *) &(map->exec[(addr - map->base) & map->mask]);
ret = *p;
} else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (map && map->read_w))
ret = map->read_w(addr, map->p);
@@ -1708,7 +1700,7 @@ mem_readl_phys(uint32_t addr)
mem_logical_addr = 0xffffffff;
if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (map && map->exec)) {
p = (uint32_t *) &(map->exec[addr - map->base]);
p = (uint32_t *) &(map->exec[(addr - map->base) & map->mask]);
ret = *p;
} else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (map && map->read_l))
ret = map->read_l(addr, map->p);
@@ -1750,7 +1742,7 @@ mem_writeb_phys(uint32_t addr, uint8_t val)
if (map) {
if (map->exec)
map->exec[addr - map->base] = val;
map->exec[(addr - map->base) & map->mask] = val;
else if (map->write_b)
map->write_b(addr, val, map->p);
}
@@ -1766,7 +1758,7 @@ mem_writew_phys(uint32_t addr, uint16_t val)
mem_logical_addr = 0xffffffff;
if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (map && map->exec)) {
p = (uint16_t *) &(map->exec[addr - map->base]);
p = (uint16_t *) &(map->exec[(addr - map->base) & map->mask]);
*p = val;
} else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (map && map->write_w))
map->write_w(addr, val, map->p);
@@ -1786,7 +1778,7 @@ mem_writel_phys(uint32_t addr, uint32_t val)
mem_logical_addr = 0xffffffff;
if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (map && map->exec)) {
p = (uint32_t *) &(map->exec[addr - map->base]);
p = (uint32_t *) &(map->exec[(addr - map->base) & map->mask]);
*p = val;
} else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (map && map->write_l))
map->write_l(addr, val, map->p);
@@ -2362,6 +2354,7 @@ mem_mapping_set(mem_mapping_t *map,
map->enable = 0;
map->base = base;
map->size = size;
map->mask = (map->size ? 0xffffffff : 0x00000000);
map->read_b = read_b;
map->read_w = read_w;
map->read_l = read_l;
@@ -2479,6 +2472,15 @@ mem_mapping_set_exec(mem_mapping_t *map, uint8_t *exec)
}
void
mem_mapping_set_mask(mem_mapping_t *map, uint32_t mask)
{
map->mask = mask;
mem_mapping_recalc(map->base, map->size);
}
void
mem_mapping_set_p(mem_mapping_t *map, void *p)
{
@@ -2560,6 +2562,8 @@ mem_a20_init(void)
{
if (is286) {
rammask = cpu_16bitbus ? 0xefffff : 0xffefffff;
if (is6117)
rammask |= 0x03000000;
flushmmucache();
mem_a20_state = mem_a20_key | mem_a20_alt;
} else {
@@ -2690,6 +2694,9 @@ mem_reset(void)
if (cpu_16bitbus) {
/* 80286/386SX; maximum address space is 16MB. */
m = 4096;
/* ALi M6117; maximum address space is 64MB. */
if (is6117)
m <<= 2;
} else {
/* 80386DX+; maximum address space is 4GB. */
m = 1048576;
@@ -2761,8 +2768,10 @@ mem_reset(void)
mem_init_ram_mapping(&ram_low_mapping, 0x000000, (mem_size > 640) ? 0xa0000 : mem_size * 1024);
if (mem_size > 1024) {
if (cpu_16bitbus && mem_size > 16256)
if (cpu_16bitbus && !is6117 && mem_size > 16256)
mem_init_ram_mapping(&ram_high_mapping, 0x100000, (16256 - 1024) * 1024);
else if (cpu_16bitbus && is6117 && mem_size > 65408)
mem_init_ram_mapping(&ram_high_mapping, 0x100000, (65408 - 1024) * 1024);
else {
if (mem_size > 1048576) {
mem_init_ram_mapping(&ram_high_mapping, 0x100000, (1048576 - 1024) * 1024);
@@ -2904,9 +2913,13 @@ mem_a20_recalc(void)
state = mem_a20_key | mem_a20_alt;
if (state && !mem_a20_state) {
rammask = (cpu_16bitbus) ? 0xffffff : 0xffffffff;
if (is6117)
rammask |= 0x03000000;
flushmmucache();
} else if (!state && mem_a20_state) {
rammask = (cpu_16bitbus) ? 0xefffff : 0xffefffff;
if (is6117)
rammask |= 0x03000000;
flushmmucache();
}

View File

@@ -451,12 +451,13 @@ static void
bios_add(void)
{
int temp_cpu_type, temp_cpu_16bitbus = 1;
int temp_is286 = 0;
int temp_is286 = 0, temp_is6117 = 0;
if (/*AT && */cpu_s) {
temp_cpu_type = cpu_s->cpu_type;
temp_cpu_16bitbus = (temp_cpu_type == CPU_286 || temp_cpu_type == CPU_386SX || temp_cpu_type == CPU_486SLC || temp_cpu_type == CPU_IBM386SLC || temp_cpu_type == CPU_IBM486SLC );
temp_is286 = (temp_cpu_type >= CPU_286);
temp_is6117 = !strcmp(cpu_f->manufacturer, "ALi");
}
if (biosmask > 0x1ffff) {
@@ -478,7 +479,15 @@ bios_add(void)
MEM_READ_ROMCS | MEM_WRITE_ROMCS);
}
if (temp_is286) {
if (temp_is6117) {
mem_mapping_add(&bios_high_mapping, biosaddr | 0x03f00000, biosmask + 1,
bios_read,bios_readw,bios_readl,
NULL,NULL,NULL,
rom, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, 0);
mem_set_mem_state_both(biosaddr | 0x03f00000, biosmask + 1,
MEM_READ_ROMCS | MEM_WRITE_ROMCS);
} else if (temp_is286) {
mem_mapping_add(&bios_high_mapping, biosaddr | (temp_cpu_16bitbus ? 0x00f00000 : 0xfff00000), biosmask + 1,
bios_read,bios_readw,bios_readl,
NULL,NULL,NULL,

View File

@@ -400,10 +400,17 @@ sst_add_mappings(sst_t *dev)
sst_write, NULL, NULL,
dev->array + fbase, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, (void *) dev);
}
mem_mapping_add(&(dev->mapping_h[i]), (base | (cpu_16bitbus ? 0xf00000 : 0xfff00000)), 0x10000,
sst_read, sst_readw, sst_readl,
sst_write, NULL, NULL,
dev->array + fbase, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, (void *) dev);
if (is6117) {
mem_mapping_add(&(dev->mapping_h[i]), (base | 0x3f00000), 0x10000,
sst_read, sst_readw, sst_readl,
sst_write, NULL, NULL,
dev->array + fbase, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, (void *) dev);
} else {
mem_mapping_add(&(dev->mapping_h[i]), (base | (cpu_16bitbus ? 0xf00000 : 0xfff00000)), 0x10000,
sst_read, sst_readw, sst_readl,
sst_write, NULL, NULL,
dev->array + fbase, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, (void *) dev);
}
}
}