aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-03-23 15:59:10 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-03-27 08:32:45 +0100
commit63a44aff7a6a2303ff1c03b6bfcfa6477943e60d (patch)
tree681c2e7dc717f2019d19e4b472323ce8d35fbe61 /src
parentde88a9628426e82f1cee4b61b06e67e6787301b1 (diff)
downloadseabios-hppa-63a44aff7a6a2303ff1c03b6bfcfa6477943e60d.zip
seabios-hppa-63a44aff7a6a2303ff1c03b6bfcfa6477943e60d.tar.gz
seabios-hppa-63a44aff7a6a2303ff1c03b6bfcfa6477943e60d.tar.bz2
pci: factor out ioconfig_cmd()
Add helper function to calculate PORT_PCI_CMD value from bdf + addr. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200323145911.22319-2-kraxel@redhat.com
Diffstat (limited to 'src')
-rw-r--r--src/hw/pci.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/hw/pci.c b/src/hw/pci.c
index 9855bad..7aca1e6 100644
--- a/src/hw/pci.c
+++ b/src/hw/pci.c
@@ -14,39 +14,44 @@
#define PORT_PCI_CMD 0x0cf8
#define PORT_PCI_DATA 0x0cfc
+static u32 ioconfig_cmd(u16 bdf, u32 addr)
+{
+ return 0x80000000 | (bdf << 8) | (addr & 0xfc);
+}
+
void pci_config_writel(u16 bdf, u32 addr, u32 val)
{
- outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD);
+ outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
outl(val, PORT_PCI_DATA);
}
void pci_config_writew(u16 bdf, u32 addr, u16 val)
{
- outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD);
+ outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
outw(val, PORT_PCI_DATA + (addr & 2));
}
void pci_config_writeb(u16 bdf, u32 addr, u8 val)
{
- outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD);
+ outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
outb(val, PORT_PCI_DATA + (addr & 3));
}
u32 pci_config_readl(u16 bdf, u32 addr)
{
- outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD);
+ outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
return inl(PORT_PCI_DATA);
}
u16 pci_config_readw(u16 bdf, u32 addr)
{
- outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD);
+ outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
return inw(PORT_PCI_DATA + (addr & 2));
}
u8 pci_config_readb(u16 bdf, u32 addr)
{
- outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD);
+ outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD);
return inb(PORT_PCI_DATA + (addr & 3));
}