From 7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 13 Aug 2020 23:59:14 -0400 Subject: FAT16 directory enumeration, making many functions static, new 'log' functions to wrap vga and serial --- src/kernel/pci.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/kernel/pci.c') diff --git a/src/kernel/pci.c b/src/kernel/pci.c index 5d8170d..28ca6c6 100644 --- a/src/kernel/pci.c +++ b/src/kernel/pci.c @@ -10,7 +10,7 @@ enum { }; uint16_t n_pci_devices = 0; -struct pci_device *pci_device_pages[256]; +static struct pci_device *pci_device_pages[256]; #define PCI_DEVICES_PER_PAGE (4096 / sizeof(struct pci_device)) @@ -29,20 +29,21 @@ struct pci_device *find_pci_device_from_class_and_subclass(uint8_t class, uint8_ return 0; } -struct pci_device *next_pci_device() { +static struct pci_device *next_pci_device() { if (!(n_pci_devices % PCI_DEVICES_PER_PAGE)) - 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_pages(1))) + panic("Out of memory in PCI enumeration"); return nth_pci_device(n_pci_devices++); } -static inline uint32_t pci_read_config(uint16_t number, uint8_t reg) { +static uint32_t pci_read_config(uint16_t number, uint8_t reg) { uint32_t cspace_addr = 0x80000000 | (number << 8) | (reg << 2); outd(PCP_SELECT, cspace_addr); return ind(PCP_READ); } -void pci_device_check(uint16_t number) { +static void pci_device_check(uint16_t number) { uint32_t id = pci_read_config(number, 0); if ((id & 0xffff) == 0xffff) return; -- cgit v1.2.3