PCI IDE check if BAR is IO
This commit is contained in:
@@ -54,6 +54,14 @@ static void ide_make_device (struct ide_probe probe) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool pci_ide_init (struct pci_info pci_info) {
|
bool pci_ide_init (struct pci_info pci_info) {
|
||||||
|
uint16_t pci_cmd = pci_read16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND);
|
||||||
|
|
||||||
|
uint16_t new_cmd = pci_cmd | (1 << 0);
|
||||||
|
|
||||||
|
if (pci_cmd != new_cmd) {
|
||||||
|
pci_write16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND, new_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
struct ide_probe probe;
|
struct ide_probe probe;
|
||||||
|
|
||||||
uint8_t progif = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_PROG_IF);
|
uint8_t progif = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_PROG_IF);
|
||||||
@@ -62,8 +70,16 @@ bool pci_ide_init (struct pci_info pci_info) {
|
|||||||
uint16_t pcmd, pctrl, scmd, sctrl;
|
uint16_t pcmd, pctrl, scmd, sctrl;
|
||||||
|
|
||||||
if ((progif & 0x01)) {
|
if ((progif & 0x01)) {
|
||||||
pcmd = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR0) & 0xFFFC);
|
uint32_t bar0 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR0);
|
||||||
pctrl = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR1) & 0xFFFC);
|
uint32_t bar1 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR1);
|
||||||
|
|
||||||
|
if (!(bar0 & PCI_BAR_IO) || !(bar1 & PCI_BAR_IO)) {
|
||||||
|
DEBUG ("Non IO BARs not supported\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcmd = (uint16_t)(bar0 & 0xFFFC);
|
||||||
|
pctrl = (uint16_t)(bar1 & 0xFFFC);
|
||||||
|
|
||||||
if (pctrl)
|
if (pctrl)
|
||||||
pctrl += 2;
|
pctrl += 2;
|
||||||
@@ -73,8 +89,16 @@ bool pci_ide_init (struct pci_info pci_info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((progif & 0x04)) {
|
if ((progif & 0x04)) {
|
||||||
scmd = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR2) & 0xFFFC);
|
uint32_t bar2 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR2);
|
||||||
sctrl = (uint16_t)(pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR3) & 0xFFFC);
|
uint32_t bar3 = pci_read32 (pci_info.bus, pci_info.slot, pci_info.func, PCI_BAR3);
|
||||||
|
|
||||||
|
if (!(bar2 & PCI_BAR_IO) || !(bar3 & PCI_BAR_IO)) {
|
||||||
|
DEBUG ("Non IO BARs not supported\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
scmd = (uint16_t)(bar2 & 0xFFFC);
|
||||||
|
sctrl = (uint16_t)(bar3 & 0xFFFC);
|
||||||
|
|
||||||
if (sctrl)
|
if (sctrl)
|
||||||
sctrl += 2;
|
sctrl += 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user