Better PCI IDE init with fallback to IO bars
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m26s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m26s
This commit is contained in:
@@ -20,6 +20,18 @@
|
||||
#define PCI_HEADER_TYPE 0x0E
|
||||
#define PCI_BIST 0x0F
|
||||
#define PCI_BAR0 0x10
|
||||
#define PCI_BAR1 0x14
|
||||
#define PCI_BAR2 0x18
|
||||
#define PCI_BAR3 0x1C
|
||||
#define PCI_BAR4 0x20
|
||||
#define PCI_BAR5 0x24
|
||||
#define PCI_INTERRUPT 0x3C
|
||||
#define PCI_SECONDARY_BUS 0x09
|
||||
|
||||
#define PCI_BAR_IO 0x01
|
||||
#define PCI_BAR_MEM32 0x02
|
||||
#define PCI_BAR_MEM64 0x04
|
||||
#define PCI_BAR_PREFETCH 0x08
|
||||
|
||||
struct pci_vendor {
|
||||
uint16_t id;
|
||||
|
||||
@@ -57,35 +57,47 @@ bool pci_ide_init (struct pci_info pci_info) {
|
||||
struct ide_probe probe;
|
||||
|
||||
uint8_t progif = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_PROG_IF);
|
||||
|
||||
DEBUG ("progif: %s\n", progif_msg[progif]);
|
||||
|
||||
switch (progif) {
|
||||
case 0x80:
|
||||
ide_probe (0x1F0, 0x3F6, 0, &probe);
|
||||
uint16_t pcmd, pctrl, scmd, sctrl;
|
||||
|
||||
if ((progif & 0x01)) {
|
||||
pcmd = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR0) & 0xFFFC);
|
||||
pctrl = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR1) & 0xFFFC);
|
||||
|
||||
if (pctrl)
|
||||
pctrl += 2;
|
||||
} else {
|
||||
pcmd = 0x1F0;
|
||||
pctrl = 0x3F6;
|
||||
}
|
||||
|
||||
if ((progif & 0x04)) {
|
||||
scmd = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR2) & 0xFFFC);
|
||||
sctrl = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR3) & 0xFFFC);
|
||||
|
||||
if (sctrl)
|
||||
sctrl += 2;
|
||||
} else {
|
||||
scmd = 0x170;
|
||||
sctrl = 0x376;
|
||||
}
|
||||
|
||||
uint16_t channels[2][2] = {{pcmd, pctrl}, {scmd, sctrl}};
|
||||
|
||||
for (size_t i = 0; i < lengthof (channels); i++) {
|
||||
uint16_t cmd = channels[i][0];
|
||||
uint16_t ctrl = channels[i][1];
|
||||
|
||||
if (cmd == 0)
|
||||
continue;
|
||||
|
||||
for (size_t dev = 0; dev < 2; dev++) {
|
||||
ide_probe (cmd, ctrl, dev, &probe);
|
||||
|
||||
if ((probe.flags & IDE_PROBE_AVAIL))
|
||||
ide_make_device (probe);
|
||||
|
||||
ide_probe (0x1F0, 0x3F6, 1, &probe);
|
||||
|
||||
if ((probe.flags & IDE_PROBE_AVAIL))
|
||||
ide_make_device (probe);
|
||||
|
||||
ide_probe (0x170, 0x376, 0, &probe);
|
||||
|
||||
if ((probe.flags & IDE_PROBE_AVAIL))
|
||||
ide_make_device (probe);
|
||||
|
||||
ide_probe (0x170, 0x376, 1, &probe);
|
||||
|
||||
if ((probe.flags & IDE_PROBE_AVAIL))
|
||||
ide_make_device (probe);
|
||||
|
||||
break;
|
||||
default:
|
||||
DEBUG ("PCI unsupported progif=%02x\n", progif);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user