diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2019-03-11 18:26:01 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-03-14 11:36:09 +0000 |
commit | 3af6aa10f7a439e97a5f7d159336b4a207a97c21 (patch) | |
tree | 37f521bf43fe3f50237ac19ac5da9d65a69255e8 /src/arch/x86 | |
parent | 125c9cf98cba524d3f8259bc34dc4c3f515403b4 (diff) | |
download | coreboot-3af6aa10f7a439e97a5f7d159336b4a207a97c21.tar.xz |
arch/x86: Optimise PCI IO config accessor
By design only 'reg' parameter can have the two least-
significant bits set. As 'reg' is often a constant,
'0xCFC + (reg & 3)' resolves to an immediate value
already at buildtime, unlike (addr & 3) which depends
of a constant (but non-immediate) value of 'dev' in
ramstage.
Change-Id: I6e729fe800c92b1ce4994ad2b4203072fa75a958
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31754
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/include/arch/pci_io_cfg.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/arch/x86/include/arch/pci_io_cfg.h b/src/arch/x86/include/arch/pci_io_cfg.h index 317c50a3fc..6c88b3cf5e 100644 --- a/src/arch/x86/include/arch/pci_io_cfg.h +++ b/src/arch/x86/include/arch/pci_io_cfg.h @@ -34,7 +34,7 @@ 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); - return inb(0xCFC + (addr & 3)); + return inb(0xCFC + (reg & 3)); } static __always_inline @@ -42,7 +42,7 @@ 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); - return inw(0xCFC + (addr & 2)); + return inw(0xCFC + (reg & 2)); } static __always_inline @@ -58,7 +58,7 @@ 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); - outb(value, 0xCFC + (addr & 3)); + outb(value, 0xCFC + (reg & 3)); } static __always_inline @@ -66,7 +66,7 @@ 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); - outw(value, 0xCFC + (addr & 2)); + outw(value, 0xCFC + (reg & 2)); } static __always_inline |