summaryrefslogtreecommitdiff
path: root/src/kernel/pci.c
diff options
context:
space:
mode:
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;