From 0503ff5d7c1630d19ca494621b4fd34a53ddc41e Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 25 Oct 2023 22:40:26 +0200 Subject: Kernel: Add basic support for PCI and rtl8139 This implementation is very messy and is currently not used. --- drivers/pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/pci.c') diff --git a/drivers/pci.c b/drivers/pci.c index cc8a42c..5fe14bd 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -54,8 +55,15 @@ int pci_populate_device_struct(uint16_t vendor, uint16_t device, continue; pci_device->bus = bus; pci_device->slot = slot; + uint32_t bar0 = pci_config_read32(pci_device, 0, 0x10); + assert(bar0 & 0x1 && "Only support memory IO"); + pci_device->gen.base_mem_io = bar0 & (~0x3); return 1; } } return 0; } + +uint8_t pci_get_interrupt_line(const struct PCI_DEVICE *device) { + return pci_config_read32(device, 0, 0x3C) & 0xFF; +} -- cgit v1.2.3