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>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/58280
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72248
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/ch341a_spi.c b/ch341a_spi.c
index 3f27298..ca131f0 100644
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -20,7 +20,6 @@
#include <string.h>
#include <libusb.h>
#include "flash.h"
-#include "platform.h"
#include "programmer.h"
/* LIBUSB_CALL ensures the right calling conventions on libusb callbacks.
diff --git a/dediprog.c b/dediprog.c
index c7f96c6..966ebe7 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 d15cc7a..6b54fc6 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 716b417..3b68233 100644
--- a/dmi.c
+++ b/dmi.c
@@ -31,7 +31,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include "platform.h"
#include "flash.h"
#include "hwaccess.h"
#include "programmer.h"
diff --git a/flash.h b/flash.h
index cda79e3..b53dcc5 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/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 @@
#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 52ca374..97fc14a 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
@@ -141,8 +139,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"
@@ -172,31 +169,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 d37d802..9cd9cf7 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 bcf48fc..4965911 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 2117642..0c33257 100644
--- a/serprog.c
+++ b/serprog.c
@@ -15,8 +15,6 @@
* GNU General Public License for more details.
*/
-#include "platform.h"
-
#include <stdbool.h>
#include <stdio.h>
#if ! IS_WINDOWS /* stuff (presumably) needed for sockets only */