diff options
author | Anton Kling <anton@kling.gg> | 2023-10-25 19:36:25 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-30 21:49:48 +0100 |
commit | 9ea708da24784d2f4960f0353b7a08c0c2c08145 (patch) | |
tree | 9d4f3ab1fbfb864ef14cd0d45ea014de0556db72 /drivers/pci.c | |
parent | 730e065e0bba1394750b3172bb7e2f1c0fd42c73 (diff) |
RTL8139: Transmission and interrupts seem to magically work now.
This commit is done to preserve the functional code before I make new
changes.
Diffstat (limited to 'drivers/pci.c')
-rw-r--r-- | drivers/pci.c | 16 |
1 files changed, 16 insertions, 0 deletions
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; |