summaryrefslogtreecommitdiff
path: root/kernel/drivers/pci.h
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-12 15:12:25 +0100
committerAnton Kling <anton@kling.gg>2023-11-12 15:12:48 +0100
commit4e34a5f97786b3bab82f08297ead63e1618744ec (patch)
tree9d95150ddb5305bfab24dedbe665939bd7a82f10 /kernel/drivers/pci.h
parent429b619013d68b98ebadc1e90f77506bcf2dbc9e (diff)
Kernel/PCI: Add functions for getting BAR and specific PCI devices by
class
Diffstat (limited to 'kernel/drivers/pci.h')
-rw-r--r--kernel/drivers/pci.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/drivers/pci.h b/kernel/drivers/pci.h
index 66d7207..3378c8b 100644
--- a/kernel/drivers/pci.h
+++ b/kernel/drivers/pci.h
@@ -1,5 +1,11 @@
#include <typedefs.h>
+struct PCI_BaseAddressRegister {
+ u32 address;
+ u32 size;
+ // TODO: Add a "type".
+};
+
struct GENERAL_DEVICE {
u32 base_mem_io;
u8 interrupt_line;
@@ -10,17 +16,21 @@ struct PCI_DEVICE {
u16 device;
u8 bus;
u8 slot;
+ u8 header_type;
union {
struct GENERAL_DEVICE gen;
};
};
-u32 pci_config_read32(const struct PCI_DEVICE *device, u8 func,
- u8 offset);
-void pci_config_write32(const struct PCI_DEVICE *device, u8 func,
- u8 offset, u32 data);
+u8 pci_get_bar(const struct PCI_DEVICE *device, u8 bar_index,
+ struct PCI_BaseAddressRegister *bar);
+u32 pci_config_read32(const struct PCI_DEVICE *device, u8 func, u8 offset);
+void pci_config_write32(const struct PCI_DEVICE *device, u8 func, u8 offset,
+ u32 data);
int pci_populate_device_struct(u16 vendor, u16 device,
struct PCI_DEVICE *pci_device);
+u8 pci_devices_by_id(u8 class_id, u8 subclass_id,
+ struct PCI_DEVICE *pci_device);
u8 pci_get_interrupt_line(const struct PCI_DEVICE *device);