diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/include/arch/pci_io_cfg.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/arch/x86/include/arch/pci_io_cfg.h b/src/arch/x86/include/arch/pci_io_cfg.h index 6c88b3cf5e..1e6934abcc 100644 --- a/src/arch/x86/include/arch/pci_io_cfg.h +++ b/src/arch/x86/include/arch/pci_io_cfg.h @@ -21,19 +21,22 @@ static __always_inline uint32_t pci_io_encode_addr(pci_devfn_t dev, uint16_t reg) { - if (CONFIG(PCI_IO_CFG_EXT)) { - // seg == 0 - return dev >> 4 | (reg & 0xff) | ((reg & 0xf00) << 16); - } else { - return dev >> 4 | reg; - } + uint32_t addr = 1 << 31; + + addr |= dev >> 4; + addr |= reg & 0xfc; + + if (CONFIG(PCI_IO_CFG_EXT)) + addr |= (reg & 0xf00) << 16; + + return addr; } static __always_inline uint8_t pci_io_read_config8(pci_devfn_t dev, uint16_t reg) { uint32_t addr = pci_io_encode_addr(dev, reg); - outl(0x80000000 | (addr & ~3), 0xCF8); + outl(addr, 0xCF8); return inb(0xCFC + (reg & 3)); } @@ -41,7 +44,7 @@ static __always_inline uint16_t pci_io_read_config16(pci_devfn_t dev, uint16_t reg) { uint32_t addr = pci_io_encode_addr(dev, reg); - outl(0x80000000 | (addr & ~3), 0xCF8); + outl(addr, 0xCF8); return inw(0xCFC + (reg & 2)); } @@ -49,7 +52,7 @@ static __always_inline uint32_t pci_io_read_config32(pci_devfn_t dev, uint16_t reg) { uint32_t addr = pci_io_encode_addr(dev, reg); - outl(0x80000000 | (addr & ~3), 0xCF8); + outl(addr, 0xCF8); return inl(0xCFC); } @@ -57,7 +60,7 @@ static __always_inline void pci_io_write_config8(pci_devfn_t dev, uint16_t reg, uint8_t value) { uint32_t addr = pci_io_encode_addr(dev, reg); - outl(0x80000000 | (addr & ~3), 0xCF8); + outl(addr, 0xCF8); outb(value, 0xCFC + (reg & 3)); } @@ -65,7 +68,7 @@ static __always_inline void pci_io_write_config16(pci_devfn_t dev, uint16_t reg, uint16_t value) { uint32_t addr = pci_io_encode_addr(dev, reg); - outl(0x80000000 | (addr & ~3), 0xCF8); + outl(addr, 0xCF8); outw(value, 0xCFC + (reg & 2)); } @@ -73,7 +76,7 @@ static __always_inline void pci_io_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value) { uint32_t addr = pci_io_encode_addr(dev, reg); - outl(0x80000000 | (addr & ~3), 0xCF8); + outl(addr, 0xCF8); outl(value, 0xCFC); } |