include/device: add pci mmio cfg address helpers

Add helpers for getting the pci mmio cfg address for a register.

Change-Id: Ie6fe22cacc7241a51d47cbe9fc64f30fa49d5a80
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36686
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Michael Niewöhner 2019-11-08 22:02:02 +01:00 committed by Patrick Georgi
parent bc2f9a30f3
commit 8f22136c05
1 changed files with 18 additions and 0 deletions

View File

@ -86,6 +86,24 @@ void pci_mmio_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value)
pcicfg(dev)->reg32[reg / sizeof(uint32_t)] = value; pcicfg(dev)->reg32[reg / sizeof(uint32_t)] = value;
} }
static __always_inline
uint8_t *pci_mmio_config8_addr(pci_devfn_t dev, uint16_t reg)
{
return (uint8_t *)&pcicfg(dev)->reg8[reg];
}
static __always_inline
uint16_t *pci_mmio_config16_addr(pci_devfn_t dev, uint16_t reg)
{
return (uint16_t *)&pcicfg(dev)->reg16[reg / sizeof(uint16_t)];
}
static __always_inline
uint32_t *pci_mmio_config32_addr(pci_devfn_t dev, uint16_t reg)
{
return (uint32_t *)&pcicfg(dev)->reg32[reg / sizeof(uint32_t)];
}
#endif /* !defined(__ROMCC__) */ #endif /* !defined(__ROMCC__) */
#if CONFIG(MMCONF_SUPPORT) #if CONFIG(MMCONF_SUPPORT)