mirror of
https://github.com/86Box/86Box.git
synced 2025-01-22 09:11:50 -05:00
CS423x: Clean up RAM download state machine
This commit is contained in:
parent
351390b579
commit
fb3469c74e
1 changed files with 16 additions and 10 deletions
|
@ -51,6 +51,12 @@ enum {
|
|||
CRYSTAL_CS4237B = 0xc8,
|
||||
CRYSTAL_CS4238B = 0xc9
|
||||
};
|
||||
enum {
|
||||
CRYSTAL_RAM_CMD = 0,
|
||||
CRYSTAL_RAM_ADDR_LO = 1,
|
||||
CRYSTAL_RAM_ADDR_HI = 2,
|
||||
CRYSTAL_RAM_DATA = 3
|
||||
};
|
||||
enum {
|
||||
CRYSTAL_SLAM_NONE = 0,
|
||||
CRYSTAL_SLAM_INDEX = 1,
|
||||
|
@ -160,7 +166,7 @@ cs423x_read(uint16_t addr, void *priv)
|
|||
/* Reading RAM is undocumented, but performed by:
|
||||
- Windows drivers (unknown purpose)
|
||||
- Intel VS440FX BIOS (PnP ROM checksum recalculation) */
|
||||
if (dev->ram_dl == 3)
|
||||
if (dev->ram_dl == CRYSTAL_RAM_DATA)
|
||||
ret = dev->ram_data[dev->ram_addr++];
|
||||
break;
|
||||
|
||||
|
@ -255,7 +261,7 @@ cs423x_write(uint16_t addr, uint8_t val, void *priv)
|
|||
|
||||
case 5: /* Control/RAM Access */
|
||||
switch (dev->ram_dl) {
|
||||
case 0: /* commands */
|
||||
case CRYSTAL_RAM_CMD: /* commands */
|
||||
switch (val) {
|
||||
case 0x55: /* Disable PnP Key */
|
||||
dev->pnp_enable = 0;
|
||||
|
@ -273,7 +279,7 @@ cs423x_write(uint16_t addr, uint8_t val, void *priv)
|
|||
break;
|
||||
|
||||
case 0xaa: /* Download RAM */
|
||||
dev->ram_dl = 1;
|
||||
dev->ram_dl = CRYSTAL_RAM_ADDR_LO;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -281,17 +287,17 @@ cs423x_write(uint16_t addr, uint8_t val, void *priv)
|
|||
}
|
||||
break;
|
||||
|
||||
case 1: /* low address byte */
|
||||
case CRYSTAL_RAM_ADDR_LO: /* low address byte */
|
||||
dev->ram_addr = val;
|
||||
dev->ram_dl++;
|
||||
dev->ram_dl = CRYSTAL_RAM_ADDR_HI;
|
||||
break;
|
||||
|
||||
case 2: /* high address byte */
|
||||
dev->ram_addr |= (val << 8);
|
||||
dev->ram_dl++;
|
||||
case CRYSTAL_RAM_ADDR_HI: /* high address byte */
|
||||
dev->ram_addr |= val << 8;
|
||||
dev->ram_dl = CRYSTAL_RAM_DATA;
|
||||
break;
|
||||
|
||||
case 3: /* data */
|
||||
case CRYSTAL_RAM_DATA: /* data */
|
||||
dev->ram_data[dev->ram_addr++] = val;
|
||||
break;
|
||||
|
||||
|
@ -303,7 +309,7 @@ cs423x_write(uint16_t addr, uint8_t val, void *priv)
|
|||
case 6: /* RAM Access End */
|
||||
/* TriGem Delhi-III BIOS writes undocumented value 0x40 instead of 0x00. */
|
||||
if ((val == 0x00) || (val == 0x40)) {
|
||||
dev->ram_dl = 0;
|
||||
dev->ram_dl = CRYSTAL_RAM_CMD;
|
||||
|
||||
/* Update PnP state and resource data. */
|
||||
cs423x_pnp_enable(dev, 1, 0);
|
||||
|
|
Loading…
Reference in a new issue