summaryrefslogtreecommitdiff
path: root/src/kernel/pci.c
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2020-08-13 23:59:14 -0400
committerBenji Dial <Benji3.141@gmail.com>2020-08-13 23:59:14 -0400
commit7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 (patch)
treee7f768ff56798bef3edc166a30e9cb8d7f25bd1e /src/kernel/pci.c
parent2ddbeb9f7214f6d3feef651eba83e6a9d120a743 (diff)
downloadportland-os-7ff724fe8f709440da9c730fdb8dcbaa4f989ed5.tar.gz
FAT16 directory enumeration, making many functions static, new 'log' functions to wrap vga and serial
Diffstat (limited to 'src/kernel/pci.c')
-rw-r--r--src/kernel/pci.c11
1 files changed, 6 insertions, 5 deletions
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;