Thomas Heijligen has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/58280 )
Change subject: platform.h: remove architicture dependend macros ......................................................................
platform.h: remove architicture dependend macros
Change-Id: Ia0f022d12390722816066d292e1878824adc613c Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.de --- M dediprog.c M developerbox_spi.c M dmi.c M flash.h M hwaccess.c M hwaccess.h M internal.c M pickit2_spi.c D platform.h M serial.c M serprog.c 11 files changed, 20 insertions(+), 113 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/80/58280/1
diff --git a/dediprog.c b/dediprog.c index 85b78c8..939673c 100644 --- a/dediprog.c +++ b/dediprog.c @@ -15,8 +15,6 @@ * GNU General Public License for more details. */
-#include "platform.h" - #include <sys/types.h> #include <stdlib.h> #include <stdio.h> diff --git a/developerbox_spi.c b/developerbox_spi.c index 5573d6f..8c4a8df 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -31,8 +31,6 @@ * should be turned on). */
-#include "platform.h" - #include <stdlib.h> #include <libusb.h> #include "programmer.h" diff --git a/dmi.c b/dmi.c index e449cd9..5d709f1 100644 --- a/dmi.c +++ b/dmi.c @@ -30,7 +30,6 @@ #include <stdio.h> #include <stdlib.h>
-#include "platform.h" #include "flash.h" #include "programmer.h"
diff --git a/flash.h b/flash.h index 3baa076..391a2d4 100644 --- a/flash.h +++ b/flash.h @@ -20,8 +20,6 @@ #ifndef __FLASH_H__ #define __FLASH_H__ 1
-#include "platform.h" - #include <inttypes.h> #include <stdio.h> #include <stdint.h> diff --git a/hwaccess.c b/hwaccess.c index 13bacd7..9bfd8ea 100644 --- a/hwaccess.c +++ b/hwaccess.c @@ -14,8 +14,6 @@ * GNU General Public License for more details. */
-#include "platform.h" - #include <stdint.h> #include <string.h> #include <stdlib.h> @@ -34,7 +32,7 @@ #include <sys/io.h> #endif
-#if IS_X86 && USE_DEV_IO +#if (defined (__i386__) || defined (__x86_64__) || defined(__amd64__)) && USE_DEV_IO int io_fd; #endif
@@ -50,9 +48,12 @@ * * See also https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documen... */ -#if IS_PPC // cf. http://lxr.free-electrons.com/source/arch/powerpc/include/asm/barrier.h +// cf. http://lxr.free-electrons.com/source/arch/powerpc/include/asm/barrier.h +#if defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \ + defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \ + defined(_ARCH_PPC64) || defined(__ppc) asm("eieio" : : : "memory"); -#elif IS_SPARC +#elif (__sparc__) || defined (__sparc) #if defined(__sparc_v9__) || defined(__sparcv9) /* Sparc V9 CPUs support three different memory orderings that range from x86-like TSO to PowerPC-like * RMO. The modes can be switched at runtime thus to make sure we maintain the right order of access we @@ -69,7 +70,7 @@ #endif }
-#if IS_X86 && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__)) +#if (defined (__i386__) || defined (__x86_64__) || defined(__amd64__)) && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__)) static int release_io_perms(void *p) { #if defined (__sun) @@ -83,13 +84,11 @@ #endif return 0; } -#endif
/* Get I/O permissions with automatic permission release on shutdown. */ int rget_io_perms(void) { -#if IS_X86 && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__)) -#if defined (__sun) + #if defined (__sun) if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) { #elif USE_DEV_IO if ((io_fd = open("/dev/io", O_RDWR)) < 0) { @@ -111,13 +110,19 @@ } else { register_shutdown(release_io_perms, NULL); } -#else - /* DJGPP and libpayload environments have full PCI port I/O permissions by default. */ - /* PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM. */ -#endif return 0; }
+#else + +/* DJGPP and libpayload environments have full PCI port I/O permissions by default. */ +/* PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM. */ +int rget_io_perms(void) +{ + return 0; +} +#endif + void mmio_writeb(uint8_t val, void *addr) { *(volatile uint8_t *) addr = val; diff --git a/hwaccess.h b/hwaccess.h index 5097ac9..56c2d1e 100644 --- a/hwaccess.h +++ b/hwaccess.h @@ -20,8 +20,6 @@ #ifndef __HWACCESS_H__ #define __HWACCESS_H__ 1
-#include "platform.h" - #if NEED_PCI == 1 /* * libpci headers use the variable name "index" which triggers shadowing @@ -109,8 +107,7 @@ #define le_to_cpu32 cpu_to_le32 #define le_to_cpu64 cpu_to_le64
-#if NEED_RAW_ACCESS == 1 -#if IS_X86 +#if NEED_RAW_ACCESS == 1 && (defined (__i386__) || defined (__x86_64__) || defined(__amd64__))
#include "hwaccess_x86_io.h"
@@ -140,31 +137,7 @@ #define wrmsr libpayload_wrmsr #endif
-#elif IS_PPC
-/* PCI port I/O is not yet implemented on PowerPC. */ - -#elif IS_MIPS - -/* PCI port I/O is not yet implemented on MIPS. */ - -#elif IS_SPARC - -/* PCI port I/O is not yet implemented on SPARC. */ - -#elif IS_ARM - -/* Non memory mapped I/O is not supported on ARM. */ - -#elif IS_ARC - -/* Non memory mapped I/O is not supported on ARC. */ - -#else - -#error Unknown architecture, please check if it supports PCI port IO. - -#endif /* IS_* */ -#endif /* NEED_RAW_ACCESS == 1 */ +#endif
#endif /* !__HWACCESS_H__ */ diff --git a/internal.c b/internal.c index b9d17b4..43bed9e 100644 --- a/internal.c +++ b/internal.c @@ -18,7 +18,6 @@ #include <string.h> #include <stdlib.h> #include "flash.h" -#include "platform.h" #include "programmer.h" #include "hwaccess.h"
diff --git a/pickit2_spi.c b/pickit2_spi.c index 17da1d9..c090efe 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -32,8 +32,6 @@ * PICkit2 code: https://github.com/steve-m/avrdude/blob/master/pickit2.c */
-#include "platform.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/platform.h b/platform.h deleted file mode 100644 index e0f8a73..0000000 --- a/platform.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the flashrom project. - * - * Copyright (C) 2011 Carl-Daniel Hailfinger - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -/* - * Header file to determine target OS and CPU architecture. - */ - -#ifndef __PLATFORM_H__ -#define __PLATFORM_H__ 1 - -// Likewise for target architectures -#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__) - #define IS_X86 1 -#elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips) - #define IS_MIPS 1 -#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \ - defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \ - defined(_ARCH_PPC64) || defined(__ppc) - #define IS_PPC 1 -#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \ - defined(__aarch64__) - #define IS_ARM 1 -#elif defined (__sparc__) || defined (__sparc) - #define IS_SPARC 1 -#elif defined (__alpha__) - #define IS_ALPHA 1 -#elif defined (__hppa__) || defined (__hppa) - #define IS_HPPA 1 -#elif defined (__m68k__) - #define IS_M68K 1 -#elif defined (__riscv) - #define IS_RISCV 1 -#elif defined (__sh__) - #define IS_SH 1 -#elif defined(__s390__) || defined(__s390x__) || defined(__zarch__) - #define IS_S390 1 -#elif defined(__arc__) - #define IS_ARC 1 -#endif - -#if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM || IS_SPARC || IS_ALPHA || IS_HPPA || IS_M68K || IS_RISCV || IS_SH || IS_S390 || IS_ARC) -#error Unknown architecture -#endif - -#endif /* !__PLATFORM_H__ */ diff --git a/serial.c b/serial.c index 76d34a2..72f9ef6 100644 --- a/serial.c +++ b/serial.c @@ -15,8 +15,6 @@ * GNU General Public License for more details. */
-#include "platform.h" - #include <stdio.h> #include <stdlib.h> #include <unistd.h> diff --git a/serprog.c b/serprog.c index b207fd2..8c73e70 100644 --- a/serprog.c +++ b/serprog.c @@ -15,8 +15,6 @@ * GNU General Public License for more details. */
-#include "platform.h" - #include <stdio.h> #if ! IS_WINDOWS /* stuff (presumably) needed for sockets only */ #include <stdlib.h>