summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heijligen <thomas.heijligen@secunet.de>2021-10-12 20:31:45 +0200
committerNico Huber <nico.h@gmx.de>2021-10-15 14:37:20 +0000
commitf42d2f72cccdbcd454a79424fdb998842f7754d6 (patch)
tree3b917ce8e8c06d597e8ebad708120b214f832003
parent1379e54f519234c07b7e0995de84ab782581c552 (diff)
downloadflashrom-f42d2f72cccdbcd454a79424fdb998842f7754d6.tar.gz
flashrom-f42d2f72cccdbcd454a79424fdb998842f7754d6.tar.bz2
flashrom-f42d2f72cccdbcd454a79424fdb998842f7754d6.zip
hwaccess: replace flashrom specific macros by compiler defines
Replace the remaining IS_* macros with the associated compiler defines Change-Id: Ia0f022d12390722816066d292e1878824adc613c Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/58280 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
-rw-r--r--dediprog.c2
-rw-r--r--developerbox_spi.c2
-rw-r--r--dmi.c1
-rw-r--r--flash.h2
-rw-r--r--hwaccess.c29
-rw-r--r--hwaccess.h31
-rw-r--r--internal.c1
-rw-r--r--pickit2_spi.c2
-rw-r--r--platform.h57
-rw-r--r--serial.c2
-rw-r--r--serprog.c2
11 files changed, 19 insertions, 112 deletions
diff --git a/dediprog.c b/dediprog.c
index 85b78c860..939673cca 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 5573d6fc6..8c4a8df82 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 e449cd9f5..5d709f1be 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 3baa07655..391a2d42f 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 13bacd7f8..9bfd8ea55 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 @@ static inline void sync_primitive(void)
*
* See also https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/memory-barriers.txt
*/
-#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 @@ static inline void sync_primitive(void)
#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 @@ static int release_io_perms(void *p)
#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,12 +110,18 @@ int rget_io_perms(void)
} else {
register_shutdown(release_io_perms, NULL);
}
+ 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. */
-#endif
+
+/* 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)
{
diff --git a/hwaccess.h b/hwaccess.h
index 5097ac99b..56c2d1e5f 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 @@ cpu_to_be(64)
#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 @@ int libpayload_wrmsr(int addr, msr_t msr);
#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 b9d17b47a..43bed9e2a 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 17da1d991..c090efe80 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 e0f8a7314..000000000
--- 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 76d34a263..72f9ef686 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 f142b492e..2bbf44b31 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>