From 966ddba554fd0d738a7d692e57d880ffe7721e43 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 20 Mar 2021 14:54:34 -0300 Subject: [PATCH] Disable DMA channels when resetting ISAPnP logical devices --- src/device/isapnp.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/device/isapnp.c b/src/device/isapnp.c index 9b8ab6923..341a9ff7e 100644 --- a/src/device/isapnp.c +++ b/src/device/isapnp.c @@ -157,6 +157,16 @@ isapnp_device_config_changed(isapnp_t *dev) } +static void +isapnp_reset_ld_regs(isapnp_device_t *ld) +{ + memset(ld->regs, 0, sizeof(ld->regs)); + + /* DMA disable uses a non-zero value. */ + ld->regs[0x74] = ld->regs[0x75] = ISAPNP_DMA_DISABLED; +} + + static uint8_t isapnp_read_rangecheck(uint16_t addr, void *priv) { @@ -356,9 +366,9 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv) while (card) { ld = card->first_ld; while (ld) { - memset(ld->regs, 0, sizeof(ld->regs)); dev->current_ld = ld; dev->current_ld_card = card; + isapnp_reset_ld_regs(ld); isapnp_device_config_changed(dev); ld = ld->next; } @@ -443,6 +453,8 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv) dev->current_ld_card = card; dev->current_ld = ld; + isapnp_reset_ld_regs(ld); + /* Logical device just created, no need to signal a change. */ if (!card->first_ld) { card->first_ld = ld;