SiS Rabbit (85c310) shadow RAM handling rewrite (fixes IDE, same as on the ACC chipset) and fixed a warning in the AD1848 code.

This commit is contained in:
OBattler
2020-06-07 01:54:19 +02:00
parent 6cf083c96d
commit 5f64a6f851
2 changed files with 61 additions and 27 deletions

View File

@@ -19,36 +19,63 @@
typedef struct typedef struct
{ {
uint8_t cur_reg, uint8_t cur_reg, tries,
regs[16]; regs[258];
} rabbit_t; } rabbit_t;
/*
static void static void
rabbit_recalcmapping(rabbit_t *dev) rabbit_recalcmapping(rabbit_t *dev)
{ {
uint32_t base; uint32_t shread, shwrite;
uint32_t i, shflags = 0; uint32_t shflags = 0;
shadowbios = 0; shread = !!(dev->regs[0x101] & 0x40);
shadowbios_write = 0; shwrite = !!(dev->regs[0x100] & 0x02);
for (i = 0; i < 8; i++) { shflags = shread ? MEM_READ_INTERNAL : MEM_READ_EXTANY;
base = 0xc0000 + (i << 15); shflags |= shwrite ? MEM_WRITE_INTERNAL : MEM_WRITE_EXTANY;
if (dev->regs[0x00] & 0x08) { shadowbios = !!shread;
shadowbios |= (base >= 0xe0000) && (dev->regs[0x02] & 0x80); shadowbios_write = !!shwrite;
shadowbios_write |= (base >= 0xe0000) && !(dev->regs[0x02] & 0x40);
shflags = (dev->regs[0x00] & 0x01) ? MEM_READ_INTERNAL : MEM_READ_EXTANY; pclog("Shadow states: C%i, E%i, R%i, W%i\n", !!(dev->regs[0x100] & 0x01), !!(dev->regs[0x100] & 0x08), shadowbios, shadowbios_write);
shflags |= (dev->regs[0x00] & 0x08) ? MEM_WRITE_EXTANY : MEM_WRITE_INTERNAL;
mem_set_mem_state(base, 0x8000, shflags); #ifdef USE_SHADOW_C0000
} else mem_set_mem_state(0x000c0000, 0x00040000, MEM_READ_EXTANY | MEM_WRITE_EXTANY);
mem_set_mem_state(base, 0x8000, MEM_READ_EXTANY | MEM_WRITE_EXTERNAL); #else
mem_set_mem_state(0x000e0000, 0x00020000, MEM_READ_EXTANY | MEM_WRITE_EXTANY);
#endif
switch (dev->regs[0x100] & 0x09) {
case 0x01:
/* The one BIOS we use seems to use something else to control C0000-DFFFF shadow,
no idea what. */
#ifdef USE_SHADOW_C0000
/* 64K at 0C0000-0CFFFF */
mem_set_mem_state(0x000c0000, 0x00010000, shflags);
/* FALLTHROUGH */
#endif
case 0x00:
/* 64K at 0F0000-0FFFFF */
mem_set_mem_state(0x000f0000, 0x00010000, shflags);
break;
case 0x09:
#ifdef USE_SHADOW_C0000
/* 128K at 0C0000-0DFFFF */
mem_set_mem_state(0x000c0000, 0x00020000, shflags);
/* FALLTHROUGH */
#endif
case 0x08:
/* 128K at 0E0000-0FFFFF */
mem_set_mem_state(0x000e0000, 0x00020000, shflags);
break;
} }
flushmmucache(); flushmmucache();
} }
*/
static void static void
rabbit_write(uint16_t addr, uint8_t val, void *priv) rabbit_write(uint16_t addr, uint8_t val, void *priv)
@@ -58,16 +85,20 @@ rabbit_write(uint16_t addr, uint8_t val, void *priv)
switch (addr) { switch (addr) {
case 0x22: case 0x22:
dev->cur_reg = val; dev->cur_reg = val;
dev->tries = 0;
pclog("[W] dev->cur_reg = %02X\n", val);
break; break;
case 0x23: case 0x23:
dev->regs[dev->cur_reg] = val; if (dev->cur_reg == 0x83) {
/* if (dev->tries < 0x02) {
if (dev->cur_reg == 0x00) { dev->regs[dev->tries++ | 0x100] = val;
rabbit_recalcmapping(dev); if (dev->tries == 0x02)
rabbit_recalcmapping(dev);
} }
*/ } else
dev->regs[dev->cur_reg] = val;
break; break;
} }
} }
@@ -79,6 +110,10 @@ rabbit_read(uint16_t addr, void *priv)
switch (addr) { switch (addr) {
case 0x23: case 0x23:
if (dev->cur_reg == 0x83) {
if (dev->tries < 0x02)
ret = dev->regs[dev->tries++ | 0x100];
} else
ret = dev->regs[dev->cur_reg]; ret = dev->regs[dev->cur_reg];
break; break;
} }
@@ -102,8 +137,7 @@ rabbit_init(const device_t *info)
rabbit_t *dev = (rabbit_t *) malloc(sizeof(rabbit_t)); rabbit_t *dev = (rabbit_t *) malloc(sizeof(rabbit_t));
memset(dev, 0, sizeof(rabbit_t)); memset(dev, 0, sizeof(rabbit_t));
io_sethandler(0x0022, 0x0001, rabbit_read, NULL, NULL, rabbit_write, NULL, NULL, dev); io_sethandler(0x0022, 0x0002, rabbit_read, NULL, NULL, rabbit_write, NULL, NULL, dev);
io_sethandler(0x0023, 0x0001, rabbit_read, NULL, NULL, rabbit_write, NULL, NULL, dev);
return dev; return dev;
} }

View File

@@ -117,7 +117,7 @@ void ad1848_write(uint16_t addr, uint8_t val, void *p)
case 24: case 24:
if (! (val & 0x70)) if (! (val & 0x70))
ad1848->status &= 0xfe; ad1848->status &= 0xfe;
break; break;
case 25: case 25:
break; break;