Merge pull request #5212 from jriwanek-forks/idesec

Support for standalone secondary IDE
This commit is contained in:
Miran Grča
2025-02-09 04:36:19 +01:00
committed by GitHub
3 changed files with 74 additions and 12 deletions

View File

@@ -2902,6 +2902,25 @@ ide_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
}
}
static void *
ide_sec_init(const device_t *info)
{
/* Don't claim this channel again if it was already claimed. */
if (ide_boards[1])
return (NULL);
ide_board_init(1, HDC_SECONDARY_IRQ, HDC_SECONDARY_BASE, HDC_SECONDARY_SIDE, info->local, info->flags);
return (ide_boards[1]);
}
/* Close a standalone IDE unit. */
static void
ide_sec_close(UNUSED(void *priv))
{
ide_board_close(1);
}
static void *
ide_ter_init(const device_t *info)
{
@@ -2920,9 +2939,8 @@ ide_ter_init(const device_t *info)
if (irq == -1)
isapnp_add_card(ide_ter_pnp_rom, sizeof(ide_ter_pnp_rom),
ide_pnp_config_changed, NULL, NULL, NULL, (void *) 2);
} else {
} else
ide_board_init(2, irq, HDC_TERTIARY_BASE, HDC_TERTIARY_SIDE, 0, 0);
}
return (ide_boards[2]);
}
@@ -3004,10 +3022,10 @@ ide_init(const device_t *info)
switch (info->local) {
case 0 ... 5:
ide_board_init(0, 14, 0x1f0, 0x3f6, info->local, info->flags);
ide_board_init(0, HDC_PRIMARY_IRQ, HDC_PRIMARY_BASE, HDC_PRIMARY_SIDE, info->local, info->flags);
if (info->local & 1)
ide_board_init(1, 15, 0x170, 0x376, info->local, info->flags);
ide_board_init(1, HDC_SECONDARY_IRQ, HDC_SECONDARY_BASE, HDC_SECONDARY_SIDE, info->local, info->flags);
break;
default:
@@ -3122,8 +3140,8 @@ static void
mcide_mca_write(const int port, const uint8_t val, void *priv)
{
mcide_t *dev = (mcide_t *) priv;
uint16_t bases[4] = { 0x01f0, 0x0170, 0x01e8, 0x0168 };
int irqs[4] = { 10, 11, 14, 15 };
uint16_t bases[4] = { HDC_PRIMARY_BASE, HDC_SECONDARY_BASE, HDC_TERTIARY_BASE, HDC_QUATERNARY_BASE };
int irqs[4] = { HDC_QUATERNARY_IRQ, HDC_TERTIARY_IRQ, HDC_PRIMARY_IRQ, HDC_SECONDARY_IRQ };
if ((port >= 0x102) && (dev->pos_regs[port & 7] != val)) {
ide_log("IDE: mcawr(%04x, %02x) pos[2]=%02x pos[3]=%02x\n",
@@ -3275,6 +3293,20 @@ const device_t ide_isa_device = {
.config = NULL
};
const device_t ide_isa_sec_device = {
.name = "ISA PC/AT IDE Controller (Secondary)",
.internal_name = "ide_isa_sec",
.flags = DEVICE_ISA | DEVICE_AT,
.local = 0,
.init = ide_init,
.close = ide_close,
.reset = ide_reset,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ide_isa_2ch_device = {
.name = "ISA PC/AT IDE Controller (Dual-Channel)",
.internal_name = "ide_isa_2ch",
@@ -3303,6 +3335,20 @@ const device_t ide_vlb_device = {
.config = NULL
};
const device_t ide_vlb_sec_device = {
.name = "VLB IDE Controller (Secondary)",
.internal_name = "ide_vlb_sec",
.flags = DEVICE_VLB | DEVICE_AT,
.local = 2,
.init = ide_init,
.close = ide_close,
.reset = ide_reset,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ide_vlb_2ch_device = {
.name = "VLB IDE Controller (Dual-Channel)",
.internal_name = "ide_vlb_2ch",
@@ -3331,6 +3377,20 @@ const device_t ide_pci_device = {
.config = NULL
};
const device_t ide_pci_sec_device = {
.name = "PCI IDE Controller (Secondary)",
.internal_name = "ide_pci_sec",
.flags = DEVICE_PCI | DEVICE_AT,
.local = 4,
.init = ide_init,
.close = ide_close,
.reset = ide_reset,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t ide_pci_2ch_device = {
.name = "PCI IDE Controller (Dual-Channel)",
.internal_name = "ide_pci_2ch",

View File

@@ -50,11 +50,13 @@ extern const device_t esdi_at_wd1007vse1_device; /* esdi_at */
extern const device_t esdi_ps2_device; /* esdi_mca */
extern const device_t ide_isa_device; /* isa_ide */
extern const device_t ide_isa_sec_device; /* isa_ide sec*/
extern const device_t ide_isa_2ch_device; /* isa_ide_2ch */
extern const device_t ide_isa_2ch_opt_device; /* isa_ide_2ch_opt */
extern const device_t ide_vlb_device; /* vlb_ide */
extern const device_t ide_vlb_sec_device; /* vlb_ide sec */
extern const device_t ide_vlb_2ch_device; /* vlb_ide_2ch */
extern const device_t ide_pci_device; /* pci_ide */
extern const device_t ide_pci_sec_device; /* pci_ide sec */
extern const device_t ide_pci_2ch_device; /* pci_ide_2ch */
extern const device_t ide_ali1489_device; /* ALi M1489 */

View File

@@ -25,17 +25,17 @@
#define IDE_BUS_MAX 4
#define IDE_CHAN_MAX 2
#define HDC_PRIMARY_BASE 0x01F0
#define HDC_PRIMARY_SIDE 0x03F6
#define HDC_PRIMARY_BASE 0x01f0
#define HDC_PRIMARY_SIDE 0x03f6
#define HDC_PRIMARY_IRQ 14
#define HDC_SECONDARY_BASE 0x0170
#define HDC_SECONDARY_SIDE 0x0376
#define HDC_SECONDARY_IRQ 15
#define HDC_TERTIARY_BASE 0x01E8
#define HDC_TERTIARY_SIDE 0x03EE
#define HDC_TERTIARY_BASE 0x01e8
#define HDC_TERTIARY_SIDE 0x03ee
#define HDC_TERTIARY_IRQ 11
#define HDC_QUATERNARY_BASE 0x0168
#define HDC_QUATERNARY_SIDE 0x036E
#define HDC_QUATERNARY_SIDE 0x036e
#define HDC_QUATERNARY_IRQ 10
enum {