PCI-IDE driver fallback to polling for PCI-native controllers
All checks were successful
Build documentation / build-and-deploy (push) Successful in 1m55s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 1m55s
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
#include <proc/reschedule.h>
|
||||
#include <sys/debug.h>
|
||||
|
||||
static atomic_int ide_counter = 0;
|
||||
static int ide_counter = 0;
|
||||
/* static bool ide_legacy_claimed = false; */
|
||||
|
||||
static const char* progif_msg[] = {
|
||||
[0x00] = "ISA Compatibility mode-only controller",
|
||||
@@ -38,7 +39,7 @@ static void ide_make_device (struct proc* proc, struct reschedule_ctx* rctx,
|
||||
probe.devno, probe.sector_size, probe.sector_count);
|
||||
|
||||
char device_key[fieldsizeof (struct device, key)];
|
||||
snprintf (device_key, sizeof (device_key), "IDE%d", atomic_fetch_add (&ide_counter, 1));
|
||||
snprintf (device_key, sizeof (device_key), "IDE%d", ide_counter++);
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[XDRV_GET_SIZE] = &idedrv_get_size,
|
||||
@@ -56,6 +57,7 @@ static void ide_make_device (struct proc* proc, struct reschedule_ctx* rctx,
|
||||
.ctrl = probe.ctrl,
|
||||
.devno = probe.devno,
|
||||
.irq = probe.irq,
|
||||
.irqs_support = probe.irqs_support,
|
||||
};
|
||||
struct device* ide = device_create (device_key, ops, lengthof (ops), &idedrv_init, &idedrv_fini,
|
||||
&init, proc, rctx);
|
||||
@@ -90,21 +92,11 @@ bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_in
|
||||
pcmd = (uint16_t)(bar0 & 0xFFFC);
|
||||
pctrl = (uint16_t)(bar1 & 0xFFFC);
|
||||
|
||||
uint8_t irq = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT);
|
||||
|
||||
if (irq == 0xFF) {
|
||||
pci_write8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT, 14);
|
||||
irq = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT);
|
||||
}
|
||||
|
||||
ioapic_route_irq (IDE_DRIVE_PRIM, irq, 0, thiscpu->lapic_id);
|
||||
DEBUG ("N pcmd=%x, pctrl=%x, irq=%u\n", pcmd, pctrl, irq);
|
||||
if (pctrl)
|
||||
pctrl += 2;
|
||||
} else {
|
||||
pcmd = 0x1F0;
|
||||
pctrl = 0x3F6;
|
||||
|
||||
ioapic_route_irq (IDE_DRIVE_PRIM, 14, 0, thiscpu->lapic_id);
|
||||
DEBUG ("L pcmd=%x, pctrl=%x, irq=%u\n", pcmd, pctrl, 14);
|
||||
}
|
||||
|
||||
if ((progif & 0x04)) {
|
||||
@@ -119,23 +111,27 @@ bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_in
|
||||
scmd = (uint16_t)(bar2 & 0xFFFC);
|
||||
sctrl = (uint16_t)(bar3 & 0xFFFC);
|
||||
|
||||
uint8_t irq = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT);
|
||||
|
||||
if (irq == 0xFF) {
|
||||
pci_write8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT, 15);
|
||||
irq = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT);
|
||||
}
|
||||
|
||||
ioapic_route_irq (IDE_DRIVE_SCND, irq, 0, thiscpu->lapic_id);
|
||||
DEBUG ("N pcmd=%x, pctrl=%x, irq=%u\n", scmd, sctrl, irq);
|
||||
if (sctrl)
|
||||
sctrl += 2;
|
||||
} else {
|
||||
scmd = 0x170;
|
||||
sctrl = 0x376;
|
||||
|
||||
ioapic_route_irq (IDE_DRIVE_SCND, 15, 0, thiscpu->lapic_id);
|
||||
DEBUG ("L pcmd=%x, pctrl=%x, irq=%u\n", scmd, sctrl, 15);
|
||||
}
|
||||
|
||||
bool irqs_support = false;
|
||||
|
||||
if ((progif & 0x05)) {
|
||||
irqs_support = false;
|
||||
} else {
|
||||
irqs_support = true;
|
||||
ioapic_route_irq (IDE_DRIVE_PRIM, 14, 0, thiscpu->lapic_id);
|
||||
ioapic_route_irq (IDE_DRIVE_SCND, 15, 0, thiscpu->lapic_id);
|
||||
}
|
||||
|
||||
DEBUG ("pcmd=%x, pctrl=%x\n", pcmd, pctrl);
|
||||
DEBUG ("scmd=%x, sctrl=%x\n", scmd, sctrl);
|
||||
DEBUG ("IRQ support=%d\n", irqs_support);
|
||||
|
||||
uint16_t channels[2][3] = {{pcmd, pctrl, IDE_DRIVE_PRIM}, {scmd, sctrl, IDE_DRIVE_SCND}};
|
||||
|
||||
for (size_t i = 0; i < lengthof (channels); i++) {
|
||||
@@ -143,15 +139,13 @@ bool pci_ide_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_in
|
||||
uint16_t ctrl = channels[i][1];
|
||||
uint8_t irq = channels[i][2];
|
||||
|
||||
if (cmd == 0)
|
||||
continue;
|
||||
|
||||
for (size_t dev = 0; dev < 2; dev++) {
|
||||
ide_probe (cmd, ctrl, dev, &probe);
|
||||
|
||||
probe.ctrl = ctrl;
|
||||
probe.io = cmd;
|
||||
probe.irq = irq;
|
||||
probe.irqs_support = irqs_support;
|
||||
|
||||
if ((probe.flags & IDE_PROBE_AVAIL))
|
||||
ide_make_device (proc, rctx, probe);
|
||||
|
||||
Reference in New Issue
Block a user