Rework PCI ata and serial drivers, program according to the progif byte
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "storedev/atasd.h"
|
||||
#include "kprintf.h"
|
||||
|
||||
#define TAG "ata"
|
||||
|
||||
#define ATA_PROBE(STRING, IOBASE, CTRLBASE, S_OR_M) \
|
||||
ps = ata_probesize_bytes((IOBASE), (CTRLBASE), (S_OR_M)); \
|
||||
if (ps > 0) { \
|
||||
@@ -27,28 +29,34 @@
|
||||
|
||||
void pci_ata_init(void) {
|
||||
PciDev dev = pci_getdev(0x8086, 0x7010, -1);
|
||||
|
||||
uint16_t iobase, ctrlbase;
|
||||
uint64_t ps;
|
||||
|
||||
uint32_t bar0 = pci_read32(dev, PCI_BAR0);
|
||||
uint32_t bar1 = pci_read32(dev, PCI_BAR1);
|
||||
uint32_t bar2 = pci_read32(dev, PCI_BAR2);
|
||||
uint32_t bar3 = pci_read32(dev, PCI_BAR3);
|
||||
static const char *progif_msg[] = {
|
||||
[0x00] = "ISA Compatibility mode-only controller",
|
||||
[0x05] = "PCI native mode-only controller",
|
||||
[0x0A] = "ISA Compatibility mode controller, supports both channels switched to PCI native mode",
|
||||
[0x0F] = "PCI native mode controller, supports both channels switched to ISA compatibility mode",
|
||||
[0x80] = "ISA Compatibility mode-only controller, supports bus mastering",
|
||||
[0x85] = "PCI native mode-only controller, supports bus mastering",
|
||||
[0x8A] = "ISA Compatibility mode controller, supports both channels switched to PCI native mode, supports bus mastering",
|
||||
[0x8F] = "PCI native mode controller, supports both channels switched to ISA compatibility mode, supports bus mastering",
|
||||
};
|
||||
|
||||
LOG("pci", "ATA bar0=0x%x, bar1=0x%x, bar2=0x%x, bar3=0x%x\n", bar0, bar1, bar2, bar3);
|
||||
uint8_t progif = pci_read8(dev, PCI_PROGIF);
|
||||
LOG("pci/"TAG, "progif=0x%02x\n", progif);
|
||||
LOG("pci/"TAG, "DESCRIPTION: %s\n", progif_msg[progif]);
|
||||
|
||||
iobase = (bar0 & 0xFFFFFFFC) + ATA_PRIM_IO * (!bar0);
|
||||
ctrlbase = (bar1 & 0xFFFFFFFC) + ATA_PRIM_CTRL * (!bar1);
|
||||
LOG("pci", "ATA CHANNEL PRIM: iobase=0x%x, ctrlbase=0x%x\n", iobase, ctrlbase);
|
||||
if (!bar0 || !bar1) LOG("pci", "falling back to ISA\n");
|
||||
ATA_PROBE("atasd0m", iobase, ctrlbase, ATA_MASTER);
|
||||
ATA_PROBE("atasd0s", iobase, ctrlbase, ATA_SLAVE);
|
||||
|
||||
iobase = (bar2 & 0xFFFFFFFC) + ATA_SCND_IO * (!bar2);
|
||||
ctrlbase = (bar3 & 0xFFFFFFFC) + ATA_SCND_CTRL * (!bar3);
|
||||
LOG("pci", "ATA CHANNEL SCND: iobase=0x%x, ctrlbase=0x%x\n", iobase, ctrlbase);
|
||||
if (!bar2 || !bar3) LOG("pci", "falling back to ISA\n");
|
||||
ATA_PROBE("atasd1m", iobase, ctrlbase, ATA_MASTER);
|
||||
ATA_PROBE("atasd2s", iobase, ctrlbase, ATA_SLAVE);
|
||||
switch (progif) {
|
||||
case 0x80: {
|
||||
uint64_t ps;
|
||||
|
||||
ATA_PROBE("atasd0m", ATA_PRIM_IO, ATA_PRIM_CTRL, ATA_MASTER);
|
||||
ATA_PROBE("atasd0s", ATA_PRIM_IO, ATA_PRIM_CTRL, ATA_SLAVE);
|
||||
|
||||
ATA_PROBE("atasd1m", ATA_SCND_IO, ATA_SCND_CTRL, ATA_MASTER);
|
||||
ATA_PROBE("atasd2s", ATA_SCND_IO, ATA_SCND_CTRL, ATA_SLAVE);
|
||||
} break;
|
||||
default:
|
||||
LOG("pci/"TAG, "Unsupported progif=0x%02x\n", progif);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user