diff --git a/src/chipset/scat.c b/src/chipset/scat.c index 3197285cc..4028cba70 100644 --- a/src/chipset/scat.c +++ b/src/chipset/scat.c @@ -1538,7 +1538,7 @@ scat_init(const device_t *info) for (i = 0; i < 16; i++) { mem_mapping_add(&dev->high_mapping[i], (i << 14) + 0xfc0000, 0x04000, bios_read, bios_readw, bios_readl, - mem_write_null, mem_write_nullw, mem_write_nulll, + NULL, NULL, NULL, rom + ((i << 14) & biosmask), 0, NULL); mem_mapping_enable(&dev->high_mapping[i]); } @@ -1558,7 +1558,7 @@ scat_init(const device_t *info) for (i = (dev->regs[SCAT_VERSION] < 4 ? 0 : 8); i < 16; i++) { mem_mapping_add(&dev->high_mapping[i], (i << 14) + 0xfc0000, 0x04000, bios_read, bios_readw, bios_readl, - mem_write_null, mem_write_nullw, mem_write_nulll, + NULL, NULL, NULL, rom + ((i << 14) & biosmask), 0, NULL); mem_mapping_enable(&dev->high_mapping[i]); } diff --git a/src/dma.c b/src/dma.c index fca5a4796..54e97f9e6 100644 --- a/src/dma.c +++ b/src/dma.c @@ -1284,7 +1284,8 @@ _dma_write(uint32_t addr, uint8_t val, dma_t *dma_c) dma_bm_write(addr, &val, 1, dma_transfer_size(dma_c)); } else { mem_writeb_phys(addr, val); - mem_invalidate_range(addr, addr); + if (AT) + mem_invalidate_range(addr, addr); } } @@ -1662,5 +1663,6 @@ dma_bm_write(uint32_t PhysAddress, const uint8_t *DataWrite, uint32_t TotalSize, mem_write_phys((void *) bytes, PhysAddress + n, TransferSize); } - mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); + if (AT) + mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); } diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index d6c93028a..6410d6d30 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -318,10 +318,6 @@ extern void mem_write_ram_2gb(uint32_t addr, uint8_t val, void *priv); extern void mem_write_ram_2gbw(uint32_t addr, uint16_t val, void *priv); extern void mem_write_ram_2gbl(uint32_t addr, uint32_t val, void *priv); -extern void mem_write_null(uint32_t addr, uint8_t val, void *p); -extern void mem_write_nullw(uint32_t addr, uint16_t val, void *p); -extern void mem_write_nulll(uint32_t addr, uint32_t val, void *p); - extern int mem_addr_is_ram(uint32_t addr); extern uint64_t mmutranslate_noabrt(uint32_t addr, int rw); diff --git a/src/mem/mem.c b/src/mem/mem.c index fcb6ccde2..b895cfb5b 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -1589,15 +1589,16 @@ uint8_t mem_readb_phys(uint32_t addr) { mem_mapping_t *map = read_mapping[addr >> MEM_GRANULARITY_BITS]; + uint8_t ret = 0xff; mem_logical_addr = 0xffffffff; if (_mem_exec[addr >> MEM_GRANULARITY_BITS]) - return _mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK]; + ret = _mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK]; else if (map && map->read_b) - return map->read_b(addr, map->p); - else - return 0xff; + ret = map->read_b(addr, map->p); + + return ret; } @@ -1605,21 +1606,21 @@ uint16_t mem_readw_phys(uint32_t addr) { mem_mapping_t *map = read_mapping[addr >> MEM_GRANULARITY_BITS]; - uint16_t temp, *p; + uint16_t ret, *p; mem_logical_addr = 0xffffffff; if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (_mem_exec[addr >> MEM_GRANULARITY_BITS])) { p = (uint16_t *) &(_mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK]); - return *p; + ret = *p; } else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (map && map->read_w)) - return map->read_w(addr, map->p); + ret = map->read_w(addr, map->p); else { - temp = mem_readb_phys(addr + 1) << 8; - temp |= mem_readb_phys(addr); + ret = mem_readb_phys(addr + 1) << 8; + ret |= mem_readb_phys(addr); } - return temp; + return ret; } @@ -1627,21 +1628,21 @@ uint32_t mem_readl_phys(uint32_t addr) { mem_mapping_t *map = read_mapping[addr >> MEM_GRANULARITY_BITS]; - uint32_t temp, *p; + uint32_t ret, *p; mem_logical_addr = 0xffffffff; if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (_mem_exec[addr >> MEM_GRANULARITY_BITS])) { p = (uint32_t *) &(_mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK]); - return *p; + ret = *p; } else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (map && map->read_l)) - return map->read_l(addr, map->p); + ret = map->read_l(addr, map->p); else { - temp = mem_readw_phys(addr + 2) << 16; - temp |= mem_readw_phys(addr); + ret = mem_readw_phys(addr + 2) << 16; + ret |= mem_readw_phys(addr); } - return temp; + return ret; } @@ -1672,7 +1673,7 @@ mem_writeb_phys(uint32_t addr, uint8_t val) mem_logical_addr = 0xffffffff; - if (_mem_exec[addr >> MEM_GRANULARITY_BITS]) + if ((_mem_exec[addr >> MEM_GRANULARITY_BITS]) && (map && map->write_b)) _mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK] = val; else if (map && map->write_b) map->write_b(addr, val, map->p); @@ -1687,7 +1688,8 @@ mem_writew_phys(uint32_t addr, uint16_t val) mem_logical_addr = 0xffffffff; - if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (_mem_exec[addr >> MEM_GRANULARITY_BITS])) { + if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (_mem_exec[addr >> MEM_GRANULARITY_BITS]) && + (map && map->write_w)) { p = (uint16_t *) &(_mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK]); *p = val; } else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_HBOUND) && (map && map->write_w)) @@ -1707,7 +1709,8 @@ mem_writel_phys(uint32_t addr, uint32_t val) mem_logical_addr = 0xffffffff; - if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (_mem_exec[addr >> MEM_GRANULARITY_BITS])) { + if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (_mem_exec[addr >> MEM_GRANULARITY_BITS]) && + (map && map->write_l)) { p = (uint32_t *) &(_mem_exec[addr >> MEM_GRANULARITY_BITS][addr & MEM_GRANULARITY_MASK]); *p = val; } else if (((addr & MEM_GRANULARITY_MASK) <= MEM_GRANULARITY_QBOUND) && (map && map->write_l)) @@ -2128,24 +2131,6 @@ mem_write_remappedl(uint32_t addr, uint32_t val, void *priv) } -void -mem_write_null(uint32_t addr, uint8_t val, void *p) -{ -} - - -void -mem_write_nullw(uint32_t addr, uint16_t val, void *p) -{ -} - - -void -mem_write_nulll(uint32_t addr, uint32_t val, void *p) -{ -} - - void mem_invalidate_range(uint32_t start_addr, uint32_t end_addr) { diff --git a/src/mem/rom.c b/src/mem/rom.c index 8e4eda437..342eaf705 100644 --- a/src/mem/rom.c +++ b/src/mem/rom.c @@ -409,7 +409,7 @@ bios_add(void) /* 256k+ BIOS'es only have low mappings at E0000-FFFFF. */ mem_mapping_add(&bios_mapping, 0xe0000, 0x20000, bios_read,bios_readw,bios_readl, - mem_write_null,mem_write_nullw,mem_write_nulll, + NULL,NULL,NULL, &rom[0x20000], MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, 0); mem_set_mem_state_both(0x0e0000, 0x20000, @@ -417,7 +417,7 @@ bios_add(void) } else { mem_mapping_add(&bios_mapping, biosaddr, biosmask + 1, bios_read,bios_readw,bios_readl, - mem_write_null,mem_write_nullw,mem_write_nulll, + NULL,NULL,NULL, rom, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, 0); mem_set_mem_state_both(biosaddr, biosmask + 1, @@ -427,7 +427,7 @@ bios_add(void) if (AT) { mem_mapping_add(&bios_high_mapping, biosaddr | (temp_cpu_16bitbus ? 0x00f00000 : 0xfff00000), biosmask + 1, bios_read,bios_readw,bios_readl, - mem_write_null,mem_write_nullw,mem_write_nulll, + NULL,NULL,NULL, rom, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROM|MEM_MAPPING_ROMCS, 0); mem_set_mem_state_both(biosaddr | (temp_cpu_16bitbus ? 0x00f00000 : 0xfff00000), biosmask + 1, @@ -536,7 +536,7 @@ rom_init(rom_t *rom, wchar_t *fn, uint32_t addr, int sz, int mask, int off, uint mem_mapping_add(&rom->mapping, addr, sz, rom_read, rom_readw, rom_readl, - mem_write_null, mem_write_nullw, mem_write_nulll, + NULL, NULL, NULL, rom->rom, flags | MEM_MAPPING_ROM, rom); return(0); @@ -566,7 +566,7 @@ rom_init_oddeven(rom_t *rom, wchar_t *fn, uint32_t addr, int sz, int mask, int o mem_mapping_add(&rom->mapping, addr, sz, rom_read, rom_readw, rom_readl, - mem_write_null, mem_write_nullw, mem_write_nulll, + NULL, NULL, NULL, rom->rom, flags | MEM_MAPPING_ROM, rom); return(0); @@ -594,7 +594,7 @@ rom_init_interleaved(rom_t *rom, wchar_t *fnl, wchar_t *fnh, uint32_t addr, int mem_mapping_add(&rom->mapping, addr, sz, rom_read, rom_readw, rom_readl, - mem_write_null, mem_write_nullw, mem_write_nulll, + NULL, NULL, NULL, rom->rom, flags | MEM_MAPPING_ROM, rom); return(0);