Alper Nebi Yasak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80373?usp=email )
Change subject: drivers/qemu/fw_cfg: Clean up #if directives ......................................................................
drivers/qemu/fw_cfg: Clean up #if directives
A previous commit adds io.h stubs for x86-style I/O port functions for other architectures, so we can avoid using #if preprocessor directives to check for x86 in the QEMU Firmware Configuration device driver. Replace them with ordinary conditions instead.
Change-Id: I554cfa7997e3c3fe910795ecd733c0ec45102011 Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com --- M src/drivers/emulation/qemu/fw_cfg.c 1 file changed, 15 insertions(+), 24 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/80373/1
diff --git a/src/drivers/emulation/qemu/fw_cfg.c b/src/drivers/emulation/qemu/fw_cfg.c index 714abfb..719ab7d 100644 --- a/src/drivers/emulation/qemu/fw_cfg.c +++ b/src/drivers/emulation/qemu/fw_cfg.c @@ -5,11 +5,8 @@ #include <string.h> #include <smbios.h> #include <console/console.h> -#if CONFIG(CPU_QEMU_X86) #include <arch/io.h> -#else #include <arch/mmio.h> -#endif #include <acpi/acpi.h> #include <commonlib/endian.h> #include <fw_cfg.h> @@ -58,27 +55,21 @@ { if (fw_ver & FW_CFG_VERSION_DMA) fw_cfg_dma(FW_CFG_DMA_CTL_SELECT | entry << 16, NULL, 0); - else { -#if CONFIG(CPU_QEMU_X86) + else if (CONFIG(CPU_QEMU_X86)) outw(entry, FW_CFG_X86_PORT_CTL); -#else + else write16((void *)FW_CFG_CTL_ADDR, be16_to_cpu(entry)); -#endif - } }
static void fw_cfg_read(void *dst, int dstlen) { if (fw_ver & FW_CFG_VERSION_DMA) fw_cfg_dma(FW_CFG_DMA_CTL_READ, dst, dstlen); - else { -#if CONFIG(CPU_QEMU_X86) + else if (CONFIG(CPU_QEMU_X86)) insb(FW_CFG_X86_PORT_DATA, dst, dstlen); -#else + else for (int i = 0; i < dstlen; i++) ((uint8_t *)dst)[i] = read8((void *)FW_CFG_DATA_ADDR); -#endif - } }
void fw_cfg_get(uint16_t entry, void *dst, int dstlen) @@ -552,17 +543,17 @@ dma_desc_addr_hi = sizeof(uintptr_t) > sizeof(uint32_t) ? (uint32_t)(dma_desc_addr >> 32) : 0;
-#if CONFIG(CPU_QEMU_X86) - // Skip writing high half if unnecessary. - if (dma_desc_addr_hi) - outl(be32_to_cpu(dma_desc_addr_hi), FW_CFG_X86_DMA_ADDR_HIGH); - outl(be32_to_cpu(dma_desc_addr_lo), FW_CFG_X86_DMA_ADDR_LOW); -#else - // Skip writing high half if unnecessary. - if (dma_desc_addr_hi) - write32((void *)FW_CFG_DMA_ADDR_HIGH, be32_to_cpu(dma_desc_addr_hi)); - write32((void *)FW_CFG_DMA_ADDR_LOW, be32_to_cpu(dma_desc_addr_lo)); -#endif + if (CONFIG(CPU_QEMU_X86)) { + // Skip writing high half if unnecessary. + if (dma_desc_addr_hi) + outl(be32_to_cpu(dma_desc_addr_hi), FW_CFG_X86_DMA_ADDR_HIGH); + outl(be32_to_cpu(dma_desc_addr_lo), FW_CFG_X86_DMA_ADDR_LOW); + } else { + // Skip writing high half if unnecessary. + if (dma_desc_addr_hi) + write32((void *)FW_CFG_DMA_ADDR_HIGH, be32_to_cpu(dma_desc_addr_hi)); + write32((void *)FW_CFG_DMA_ADDR_LOW, be32_to_cpu(dma_desc_addr_lo)); + }
while (be32_to_cpu(dma.control) & ~FW_CFG_DMA_CTL_ERROR) ;