summaryrefslogtreecommitdiff
path: root/hwaccess.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2015-01-10 09:32:50 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2015-01-10 09:32:50 +0000
commita944b6ad6fa81aa88b7f10ce4fbd7eb0577b32ee (patch)
treefcba10fdf1451557f3bc58de6f39d669e5106c46 /hwaccess.c
parentc3a79baaa34f56c6a7e92798778810c57c44974c (diff)
downloadflashrom-a944b6ad6fa81aa88b7f10ce4fbd7eb0577b32ee.tar.gz
Unify target OS and CPU architecture checks.
We do CPU architecture checks once for the makefile in arch.h and once for HW access abstraction in hwaccess.c. This patch unifies related files so that they can share the checks to improve maintainability and reduce the chance of inconsistencies. Furthermore, it refines some of the definitions, which - adds "support" for AARCH64 and PPC64, - adds big-endian handling on arm as well as LE handling on PPC64, - fixes compilation of internal.c on AARCH64 and PPC64. Additionally, this patch continues to unify all OS checks in flashrom by adding a new helper macro IS_WINDOWS. The old header file for architecture checking is renamed to platform.h to reflect its broader scope and all new macros are add in there. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1864 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'hwaccess.c')
-rw-r--r--hwaccess.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/hwaccess.c b/hwaccess.c
index 5b18c32..c90490b 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -18,19 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define IS_X86 (defined(__i386__) || defined(__x86_64__) || defined(__amd64__))
-#define IS_MIPS (defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips))
-#define IS_PPC (defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__))
-#define IS_ARM (defined (__arm__) || defined (_ARM))
-#if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM)
-#error Unknown architecture
-#endif
-
-#define IS_LINUX (defined(__gnu_linux__) || defined(__linux__))
-#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__))
-#if !(IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__DJGPP__) || defined(__LIBPAYLOAD__) || defined(__sun))
-#error "Unknown operating system"
-#endif
+#include "platform.h"
#include <stdint.h>
#include <string.h>
@@ -45,6 +33,10 @@
#include "flash.h"
#include "hwaccess.h"
+#if !(IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__DJGPP__) || defined(__LIBPAYLOAD__) || defined(__sun))
+#error "Unknown operating system"
+#endif
+
#define USE_IOPL (IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__))
#define USE_DEV_IO (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__))
@@ -62,7 +54,7 @@ static inline void sync_primitive(void)
* - MIPS uses uncached accesses in mode 2 on /dev/mem which has also a strongly ordered memory model
* - ARM uses a strongly ordered memory model for device memories.
*/
-#if IS_PPC
+#if IS_PPC // cf. http://lxr.free-electrons.com/source/arch/powerpc/include/asm/barrier.h
asm("eieio" : : : "memory");
#endif
}