PIIX: Implement drive separation on IDE I/O traps

This commit is contained in:
RichardG867
2021-10-19 00:17:27 -03:00
parent 8e823f125c
commit 04bea78e5e
2 changed files with 66 additions and 53 deletions

View File

@@ -41,6 +41,8 @@
#include <86box/pic.h> #include <86box/pic.h>
#include <86box/pit.h> #include <86box/pit.h>
#include <86box/port_92.h> #include <86box/port_92.h>
#include <86box/scsi_device.h>
#include <86box/hdc.h>
#include <86box/hdc_ide.h> #include <86box/hdc_ide.h>
#include <86box/hdc_ide_sff8038i.h> #include <86box/hdc_ide_sff8038i.h>
#include <86box/usb.h> #include <86box/usb.h>
@@ -284,6 +286,17 @@ piix_trap_io(int size, uint16_t addr, uint8_t write, uint8_t val, void *priv)
} }
static void
piix_trap_io_ide(int size, uint16_t addr, uint8_t write, uint8_t val, void *priv)
{
piix_io_trap_t *trap = (piix_io_trap_t *) priv;
/* IDE traps are per drive, not per channel. */
if (ide_drives[trap->dev_id]->selected)
piix_trap_io(size, addr, write, val, priv);
}
static void static void
piix_trap_update_devctl(piix_t *dev, uint8_t trap_id, uint8_t dev_id, piix_trap_update_devctl(piix_t *dev, uint8_t trap_id, uint8_t dev_id,
uint32_t devctl_mask, uint8_t enable, uint32_t devctl_mask, uint8_t enable,
@@ -295,7 +308,7 @@ piix_trap_update_devctl(piix_t *dev, uint8_t trap_id, uint8_t dev_id,
/* Set up Device I/O traps dynamically. */ /* Set up Device I/O traps dynamically. */
if (enable && !trap->trap) { if (enable && !trap->trap) {
trap->dev = dev; trap->dev = dev;
trap->trap = io_trap_add(piix_trap_io, trap); trap->trap = io_trap_add((dev_id <= 3) ? piix_trap_io_ide : piix_trap_io, trap);
trap->dev_id = dev_id; trap->dev_id = dev_id;
trap->sts_reg = &dev->acpi->regs.devsts; trap->sts_reg = &dev->acpi->regs.devsts;
trap->sts_mask = 0x00010000 << dev_id; trap->sts_mask = 0x00010000 << dev_id;