diff --git a/kernel-src/include/kernel/pci.h b/kernel-src/include/kernel/pci.h index 6c780ba1..5b5f0f24 100644 --- a/kernel-src/include/kernel/pci.h +++ b/kernel-src/include/kernel/pci.h @@ -5,6 +5,8 @@ #include #include +#define PCI_BAR_BASE 0x10 + // 2 byte fields #define PCI_CONFIG_VENDOR 0x0 #define PCI_CONFIG_DEVICEID 0x2 @@ -37,8 +39,10 @@ typedef struct { typedef struct { uintptr_t address; + uintptr_t physical; size_t length; bool mmio; + bool is64bits; bool prefetchable; } pcibar_t; diff --git a/kernel-src/io/pci.c b/kernel-src/io/pci.c index d77c54c6..aff026f7 100644 --- a/kernel-src/io/pci.c +++ b/kernel-src/io/pci.c @@ -146,9 +146,10 @@ pcibar_t pci_getbar(pcienum_t *e, int n) { } else { ret.mmio = true; ret.prefetchable = bar & BAR_PREFETCHABLE; - ret.address = bar & 0xfffffff0; + ret.address = ret.physical = bar & 0xfffffff0; ret.length = -1; - if ((bar & BAR_TYPE_MASK) == BAR_TYPE_64BIT) + ret.is64bits = (bar & BAR_TYPE_MASK) == BAR_TYPE_64BIT; + if (ret.is64bits) ret.address += (uint64_t)pci_read32(e->bus, e->device, e->function, offset + 4) << 32; pci_write32(e->bus, e->device, e->function, offset, -1);