diff options
Diffstat (limited to 'src/kernel/pci.c')
-rw-r--r-- | src/kernel/pci.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/kernel/pci.c b/src/kernel/pci.c index 28ca6c6..9e33e49 100644 --- a/src/kernel/pci.c +++ b/src/kernel/pci.c @@ -1,7 +1,7 @@ #include "panic.h" #include "boot.h" #include "util.h" -#include "mem.h" +#include "pmap.h" #include "pci.h" enum { @@ -9,7 +9,7 @@ enum { PCP_READ = 0x0cfc }; -uint16_t n_pci_devices = 0; +uint16_t n_pci_devices; static struct pci_device *pci_device_pages[256]; #define PCI_DEVICES_PER_PAGE (4096 / sizeof(struct pci_device)) @@ -31,7 +31,7 @@ struct pci_device *find_pci_device_from_class_and_subclass(uint8_t class, uint8_ static struct pci_device *next_pci_device() { if (!(n_pci_devices % PCI_DEVICES_PER_PAGE)) - if (!(pci_device_pages[n_pci_devices / PCI_DEVICES_PER_PAGE] = allocate_pages(1))) + if (!(pci_device_pages[n_pci_devices / PCI_DEVICES_PER_PAGE] = allocate_kernel_pages(1))) panic("Out of memory in PCI enumeration"); return nth_pci_device(n_pci_devices++); } @@ -68,6 +68,8 @@ void pci_init() { if (!(BOOT_INFO->pci_hw_char & PHC_CS_M1)) panic("No PCI Mechanism 1 support"); + n_pci_devices = 0; + for (uint32_t number = 0; number < (BOOT_INFO->last_pci_bus + 1) * 256; ++number) pci_device_check(number); }
\ No newline at end of file |