From e8c6577617bffa4402c07c7aa20e3c24f03c1c20 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 6 Sep 2020 00:48:07 -0400 Subject: program loading, others big kernel additions: paging, elf loading, separate kernel and user page allocation it now properly loads and runs sd0:bin/init.elf still need to determine which disk was booted from, and start the init on that disk --- src/kernel/pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/kernel/pci.c') 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 -- cgit v1.2.3