From 9ea708da24784d2f4960f0353b7a08c0c2c08145 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 25 Oct 2023 19:36:25 +0200 Subject: RTL8139: Transmission and interrupts seem to magically work now. This commit is done to preserve the functional code before I make new changes. --- drivers/pci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/pci.c') diff --git a/drivers/pci.c b/drivers/pci.c index a71cc9a..cc8a42c 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -5,6 +5,22 @@ #define CONFIG_ADDRESS 0xCF8 #define CONFIG_DATA 0xCFC +void pci_config_write32(const struct PCI_DEVICE *device, uint8_t func, + uint8_t offset, uint32_t data) { + uint32_t address; + uint32_t lbus = (uint32_t)device->bus; + uint32_t lslot = (uint32_t)device->slot; + uint32_t lfunc = (uint32_t)func; + + // Create configuration address as per Figure 1 + address = (uint32_t)((lbus << 16) | (lslot << 11) | (lfunc << 8) | + (offset & 0xFC) | ((uint32_t)0x80000000)); + + // Write out the address + outl(CONFIG_ADDRESS, address); + outl(CONFIG_DATA, data); +} + uint32_t pci_config_read32(const struct PCI_DEVICE *device, uint8_t func, uint8_t offset) { uint32_t address; -- cgit v1.2.3