diff --git a/src/include/86box/mem.h b/src/include/86box/mem.h index ad89e4b4f..87be14d5b 100644 --- a/src/include/86box/mem.h +++ b/src/include/86box/mem.h @@ -179,6 +179,7 @@ typedef struct _mem_mapping_ { uint32_t base; uint32_t size; + uint32_t base_ignore; uint32_t mask; uint8_t (*read_b)(uint32_t addr, void *priv); @@ -400,6 +401,7 @@ extern void mem_mapping_set_p(mem_mapping_t *, void *priv); extern void mem_mapping_set_addr(mem_mapping_t *, uint32_t base, uint32_t size); +extern void mem_mapping_set_base_ignore(mem_mapping_t *, uint32_t base_ignore); extern void mem_mapping_set_exec(mem_mapping_t *, uint8_t *exec); extern void mem_mapping_set_mask(mem_mapping_t *, uint32_t mask); extern void mem_mapping_disable(mem_mapping_t *); diff --git a/src/mem/mem.c b/src/mem/mem.c index 57dc31e33..70e33ca7e 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -2351,41 +2351,47 @@ mem_mapping_recalc(uint64_t base, uint64_t size) /* In range? */ if (map->enable && (uint64_t) map->base < ((uint64_t) base + (uint64_t) size) && ((uint64_t) map->base + (uint64_t) map->size) > (uint64_t) base) { + uint64_t i_a = (~map->base_ignore) + 0x00000001ULL; + uint64_t i_s = 0x00000000ULL; + uint64_t i_e = map->base_ignore; + uint64_t i_c = 0x00000000ULL; uint64_t start = (map->base < base) ? map->base : base; uint64_t end = (((uint64_t) map->base + (uint64_t) map->size) < (base + size)) ? ((uint64_t) map->base + (uint64_t) map->size) : (base + size); if (start < map->base) start = map->base; - for (c = start; c < end; c += MEM_GRANULARITY_SIZE) { - /* CPU */ - n = !!in_smm; - wp = _mem_wp[c >> MEM_GRANULARITY_BITS]; + for (i_c = i_s; i_c <= i_e; i_c += i_a) { + for (c = (start + i_c); c < (end + i_c); c += MEM_GRANULARITY_SIZE) { + /* CPU */ + n = !!in_smm; + wp = _mem_wp[c >> MEM_GRANULARITY_BITS]; - if (map->exec && mem_mapping_access_allowed(map->flags, - _mem_state[c >> MEM_GRANULARITY_BITS].states[n].x)) - _mem_exec[c >> MEM_GRANULARITY_BITS] = map->exec + (c - map->base); - if (!wp && (map->write_b || map->write_w || map->write_l) && - mem_mapping_access_allowed(map->flags, - _mem_state[c >> MEM_GRANULARITY_BITS].states[n].w)) - write_mapping[c >> MEM_GRANULARITY_BITS] = map; - if ((map->read_b || map->read_w || map->read_l) && - mem_mapping_access_allowed(map->flags, - _mem_state[c >> MEM_GRANULARITY_BITS].states[n].r)) - read_mapping[c >> MEM_GRANULARITY_BITS] = map; + if (map->exec && mem_mapping_access_allowed(map->flags, + _mem_state[c >> MEM_GRANULARITY_BITS].states[n].x)) + _mem_exec[c >> MEM_GRANULARITY_BITS] = map->exec + (c - map->base); + if (!wp && (map->write_b || map->write_w || map->write_l) && + mem_mapping_access_allowed(map->flags, + _mem_state[c >> MEM_GRANULARITY_BITS].states[n].w)) + write_mapping[c >> MEM_GRANULARITY_BITS] = map; + if ((map->read_b || map->read_w || map->read_l) && + mem_mapping_access_allowed(map->flags, + _mem_state[c >> MEM_GRANULARITY_BITS].states[n].r)) + read_mapping[c >> MEM_GRANULARITY_BITS] = map; - /* Bus */ - n |= STATE_BUS; - wp = _mem_wp_bus[c >> MEM_GRANULARITY_BITS]; + /* Bus */ + n |= STATE_BUS; + wp = _mem_wp_bus[c >> MEM_GRANULARITY_BITS]; - if (!wp && (map->write_b || map->write_w || map->write_l) && - mem_mapping_access_allowed(map->flags, - _mem_state[c >> MEM_GRANULARITY_BITS].states[n].w)) - write_mapping_bus[c >> MEM_GRANULARITY_BITS] = map; - if ((map->read_b || map->read_w || map->read_l) && - mem_mapping_access_allowed(map->flags, - _mem_state[c >> MEM_GRANULARITY_BITS].states[n].r)) - read_mapping_bus[c >> MEM_GRANULARITY_BITS] = map; + if (!wp && (map->write_b || map->write_w || map->write_l) && + mem_mapping_access_allowed(map->flags, + _mem_state[c >> MEM_GRANULARITY_BITS].states[n].w)) + write_mapping_bus[c >> MEM_GRANULARITY_BITS] = map; + if ((map->read_b || map->read_w || map->read_l) && + mem_mapping_access_allowed(map->flags, + _mem_state[c >> MEM_GRANULARITY_BITS].states[n].r)) + read_mapping_bus[c >> MEM_GRANULARITY_BITS] = map; + } } } map = map->next; @@ -2597,6 +2603,20 @@ mem_mapping_set_addr(mem_mapping_t *map, uint32_t base, uint32_t size) mem_mapping_recalc(map->base, map->size); } +void +mem_mapping_set_base_ignore(mem_mapping_t *map, uint32_t base_ignore) +{ + /* Remove old mapping. */ + map->enable = 0; + mem_mapping_recalc(map->base, map->size); + + /* Set new mapping. */ + map->enable = 1; + map->base_ignore = base_ignore; + + mem_mapping_recalc(map->base, map->size); +} + void mem_mapping_set_exec(mem_mapping_t *map, uint8_t *exec) { diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index 1adcc14ec..26184dd17 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -4306,6 +4306,9 @@ gd54xx_init(const device_t *info) mem_mapping_disable(&gd54xx->bios_rom.mapping); } + if ((svga->crtc[0x27] <= CIRRUS_ID_CLGD5429) || (!gd54xx->pci && !gd54xx->vlb)) + mem_mapping_set_base_ignore(&gd54xx->linear_mapping, 0xff000000); + mem_mapping_set_p(&svga->mapping, gd54xx); mem_mapping_disable(&gd54xx->mmio_mapping); mem_mapping_disable(&gd54xx->linear_mapping);