From 587d7330e15ab80bce7a96887f941b85cce5c415 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 20 Mar 2021 05:50:37 +0100 Subject: [PATCH 1/2] Fixed ISA PNP segmentation faults when card is NULL, fixes the Shuttle HOT-557. --- src/device/isapnp.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/device/isapnp.c b/src/device/isapnp.c index 9b8ab6923..74018cf4d 100644 --- a/src/device/isapnp.c +++ b/src/device/isapnp.c @@ -211,6 +211,11 @@ isapnp_read_data(uint16_t addr, void *priv) case 0x04: /* Resource Data */ CHECK_CURRENT_CARD(); + /* The break; inside CHECK_CURRENT_CARD(); only breaks out of the do { ... } while (0); + so make sure to break again here. */ + if (!card) + break; + isapnp_log("ISAPnP: Read resource data index %02X (%02X) from CSN %02X\n", card->rom_pos, card->rom[card->rom_pos], card->csn); if (card->rom_pos >= card->rom_size) ret = 0xff; @@ -223,6 +228,11 @@ isapnp_read_data(uint16_t addr, void *priv) ret = 0x00; CHECK_CURRENT_CARD(); + /* The break; inside CHECK_CURRENT_CARD(); only breaks out of the do { ... } while (0); + so make sure to break again here. */ + if (!card) + break; + isapnp_log("ISAPnP: Query status for CSN %02X\n", card->csn); ret = 0x01; @@ -232,6 +242,11 @@ isapnp_read_data(uint16_t addr, void *priv) ret = 0x00; CHECK_CURRENT_CARD(); + /* The break; inside CHECK_CURRENT_CARD(); only breaks out of the do { ... } while (0); + so make sure to break again here. */ + if (!card) + break; + isapnp_log("ISAPnP: Query CSN %02X\n", card->csn); ret = card->csn; @@ -251,7 +266,14 @@ isapnp_read_data(uint16_t addr, void *priv) case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: CHECK_CURRENT_CARD(); + + /* The break; inside CHECK_CURRENT_CARD(); only breaks out of the do { ... } while (0); + so make sure to break again here. */ + if (!card) + break; + isapnp_log("ISAPnP: Read vendor-defined register %02X from CSN %02X\n", dev->reg, card->csn); + if (card->read_vendor_reg) ret = card->read_vendor_reg(0, dev->reg, card->priv); break; @@ -422,6 +444,11 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv) case 0x07: /* Logical Device Number */ CHECK_CURRENT_CARD(); + /* The break; inside CHECK_CURRENT_CARD(); only breaks out of the do { ... } while (0); + so make sure to break again here. */ + if (!card) + break; + ld = card->first_ld; while (ld) { if (ld->number == val) { @@ -486,7 +513,14 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv) case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: CHECK_CURRENT_CARD(); + + /* The break; inside CHECK_CURRENT_CARD(); only breaks out of the do { ... } while (0); + so make sure to break again here. */ + if (!card) + break; + isapnp_log("ISAPnP: Write %02X to vendor-defined register %02X on CSN %02X\n", val, dev->reg, card->csn); + if (card->write_vendor_reg) card->write_vendor_reg(0, dev->reg, val, card->priv); break; From c54c4c842c82542b0b980c11f2c50373e5335e01 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 20 Mar 2021 19:41:07 +0100 Subject: [PATCH 2/2] Fixed AHA-154xCF FDC port configuration via EEPROM. --- src/scsi/scsi_aha154x.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index e374de25e..8e4bf93be 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -193,7 +193,7 @@ aha154x_eeprom(x54x_t *dev, uint8_t cmd,uint8_t arg,uint8_t len,uint8_t off,uint if (dev->type == AHA_154xCF) { if (dev->fdc_address > 0) { fdc_remove(dev->fdc); - fdc_set_base(dev->fdc, dev->fdc_address); + fdc_set_base(dev->fdc, (dev->nvr[0] & EE0_ALTFLOP) ? 0x370 : 0x3f0); } } } @@ -745,6 +745,13 @@ aha_setnvr(x54x_t *dev) f = NULL; } else aha_initnvr(dev); + + if (dev->type == AHA_154xCF) { + if (dev->fdc_address > 0) { + fdc_remove(dev->fdc); + fdc_set_base(dev->fdc, (dev->nvr[0] & EE0_ALTFLOP) ? 0x370 : 0x3f0); + } + } }