From 1b2d95feb30e30ccd6281117593ea1ae974fc480 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Thu, 18 May 2017 15:56:22 +0200 Subject: arch/x86/include: Use IS_ENABLED() macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0f9a92e595ec765d47f89f0023ff69636ee406af Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/19761 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) Reviewed-by: Philippe Mathieu-Daudé --- src/arch/x86/include/arch/bootblock_romcc.h | 2 +- src/arch/x86/include/arch/cpu.h | 2 +- src/arch/x86/include/arch/interrupt.h | 4 +-- src/arch/x86/include/arch/pci_io_cfg.h | 53 +++++++++-------------------- src/arch/x86/include/arch/pirq_routing.h | 4 +-- 5 files changed, 23 insertions(+), 42 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/include/arch/bootblock_romcc.h b/src/arch/x86/include/arch/bootblock_romcc.h index d6962d69f8..600d360749 100644 --- a/src/arch/x86/include/arch/bootblock_romcc.h +++ b/src/arch/x86/include/arch/bootblock_romcc.h @@ -46,7 +46,7 @@ static void bootblock_mainboard_init(void) } #endif -#if CONFIG_USE_OPTION_TABLE +#if IS_ENABLED(CONFIG_USE_OPTION_TABLE) static void sanitize_cmos(void) { if (cmos_error() || !cmos_chksum_valid() diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h index 06e4435699..8a44ef96c0 100644 --- a/src/arch/x86/include/arch/cpu.h +++ b/src/arch/x86/include/arch/cpu.h @@ -188,7 +188,7 @@ struct thread; struct cpu_info { struct device *cpu; unsigned int index; -#if CONFIG_COOP_MULTITASKING +#if IS_ENABLED(CONFIG_COOP_MULTITASKING) struct thread *thread; #endif }; diff --git a/src/arch/x86/include/arch/interrupt.h b/src/arch/x86/include/arch/interrupt.h index 90a29afd91..3373e8223b 100644 --- a/src/arch/x86/include/arch/interrupt.h +++ b/src/arch/x86/include/arch/interrupt.h @@ -21,9 +21,9 @@ #include "registers.h" /* setup interrupt handlers for mainboard */ -#if CONFIG_PCI_OPTION_ROM_RUN_REALMODE +#if IS_ENABLED(CONFIG_PCI_OPTION_ROM_RUN_REALMODE) extern void mainboard_interrupt_handlers(int intXX, int (*intXX_func)(void)); -#elif CONFIG_PCI_OPTION_ROM_RUN_YABEL +#elif IS_ENABLED(CONFIG_PCI_OPTION_ROM_RUN_YABEL) #include #else static inline void mainboard_interrupt_handlers(int intXX, diff --git a/src/arch/x86/include/arch/pci_io_cfg.h b/src/arch/x86/include/arch/pci_io_cfg.h index 8802cc0616..a09b488032 100644 --- a/src/arch/x86/include/arch/pci_io_cfg.h +++ b/src/arch/x86/include/arch/pci_io_cfg.h @@ -16,15 +16,21 @@ #include +static inline __attribute__((always_inline)) +unsigned int pci_io_encode_addr(pci_devfn_t dev, unsigned int where) +{ + if (IS_ENABLED(CONFIG_PCI_IO_CFG_EXT)) { + // seg == 0 + return dev >> 4 | (where & 0xff) | ((where & 0xf00) << 16); + } else { + return dev >> 4 | where; + } +} + static inline __attribute__((always_inline)) uint8_t pci_io_read_config8(pci_devfn_t dev, unsigned int where) { - unsigned int addr; -#if !CONFIG_PCI_IO_CFG_EXT - addr = (dev>>4) | where; -#else - addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16); //seg == 0 -#endif + unsigned int addr = pci_io_encode_addr(dev, where); outl(0x80000000 | (addr & ~3), 0xCF8); return inb(0xCFC + (addr & 3)); } @@ -32,12 +38,7 @@ uint8_t pci_io_read_config8(pci_devfn_t dev, unsigned int where) static inline __attribute__((always_inline)) uint16_t pci_io_read_config16(pci_devfn_t dev, unsigned int where) { - unsigned int addr; -#if !CONFIG_PCI_IO_CFG_EXT - addr = (dev>>4) | where; -#else - addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16); -#endif + unsigned int addr = pci_io_encode_addr(dev, where); outl(0x80000000 | (addr & ~3), 0xCF8); return inw(0xCFC + (addr & 2)); } @@ -45,12 +46,7 @@ uint16_t pci_io_read_config16(pci_devfn_t dev, unsigned int where) static inline __attribute__((always_inline)) uint32_t pci_io_read_config32(pci_devfn_t dev, unsigned int where) { - unsigned int addr; -#if !CONFIG_PCI_IO_CFG_EXT - addr = (dev>>4) | where; -#else - addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16); -#endif + unsigned int addr = pci_io_encode_addr(dev, where); outl(0x80000000 | (addr & ~3), 0xCF8); return inl(0xCFC); } @@ -58,12 +54,7 @@ uint32_t pci_io_read_config32(pci_devfn_t dev, unsigned int where) static inline __attribute__((always_inline)) void pci_io_write_config8(pci_devfn_t dev, unsigned int where, uint8_t value) { - unsigned int addr; -#if !CONFIG_PCI_IO_CFG_EXT - addr = (dev>>4) | where; -#else - addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16); -#endif + unsigned int addr = pci_io_encode_addr(dev, where); outl(0x80000000 | (addr & ~3), 0xCF8); outb(value, 0xCFC + (addr & 3)); } @@ -71,12 +62,7 @@ void pci_io_write_config8(pci_devfn_t dev, unsigned int where, uint8_t value) static inline __attribute__((always_inline)) void pci_io_write_config16(pci_devfn_t dev, unsigned int where, uint16_t value) { - unsigned int addr; -#if !CONFIG_PCI_IO_CFG_EXT - addr = (dev>>4) | where; -#else - addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16); -#endif + unsigned int addr = pci_io_encode_addr(dev, where); outl(0x80000000 | (addr & ~3), 0xCF8); outw(value, 0xCFC + (addr & 2)); } @@ -84,12 +70,7 @@ void pci_io_write_config16(pci_devfn_t dev, unsigned int where, uint16_t value) static inline __attribute__((always_inline)) void pci_io_write_config32(pci_devfn_t dev, unsigned int where, uint32_t value) { - unsigned int addr; -#if !CONFIG_PCI_IO_CFG_EXT - addr = (dev>>4) | where; -#else - addr = (dev>>4) | (where & 0xff) | ((where & 0xf00)<<16); -#endif + unsigned int addr = pci_io_encode_addr(dev, where); outl(0x80000000 | (addr & ~3), 0xCF8); outl(value, 0xCFC); } diff --git a/src/arch/x86/include/arch/pirq_routing.h b/src/arch/x86/include/arch/pirq_routing.h index acd456b173..ed80ce53ac 100644 --- a/src/arch/x86/include/arch/pirq_routing.h +++ b/src/arch/x86/include/arch/pirq_routing.h @@ -27,7 +27,7 @@ * CAUTION: If you change this, pirq_routing will not work correctly*/ #define MAX_INTX_ENTRIES 4 -#if CONFIG_GENERATE_PIRQ_TABLE +#if IS_ENABLED(CONFIG_GENERATE_PIRQ_TABLE) #include #define PIRQ_SIGNATURE (('$' << 0) + ('P' << 8) + ('I' << 16) + ('R' << 24)) @@ -60,7 +60,7 @@ unsigned long copy_pirq_routing_table(unsigned long addr, const struct irq_routing_table *routing_table); unsigned long write_pirq_routing_table(unsigned long start); -#if CONFIG_PIRQ_ROUTE +#if IS_ENABLED(CONFIG_PIRQ_ROUTE) void pirq_assign_irqs(const unsigned char pirq[CONFIG_MAX_PIRQ_LINKS]); #endif -- cgit v1.2.3