Endian conversion: move to platform.h and platform/endian*.c

Starting to move the platform dependent code to platform/ and provide
the abstraction through the platform.h header.

Change-Id: I35640282d451960f2a329ae24339ec05dbae6d30
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/62899
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72316
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/Makefile b/Makefile
index 7692b98..64e6fb8 100644
--- a/Makefile
+++ b/Makefile
@@ -383,7 +383,7 @@
 # Library code.
 
 LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o programmer_table.o \
-	helpers.o ich_descriptors.o fmap.o hwaccess_endian_$(ENDIAN).o
+	helpers.o ich_descriptors.o fmap.o platform/endian_$(ENDIAN).o
 
 
 ###############################################################################
@@ -952,7 +952,8 @@
 # This includes all frontends and libflashrom.
 # We don't use EXEC_SUFFIX here because we want to clean everything.
 clean:
-	rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a $(filter-out Makefile.d, $(wildcard *.d *.o)) $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
+	rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a $(filter-out Makefile.d, $(wildcard *.d *.o platform/*.d platform/*.o)) \
+		$(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
 	@+$(MAKE) -C util/ich_descriptors_tool/ clean
 
 install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
diff --git a/hwaccess_physmap.c b/hwaccess_physmap.c
index 5644680..1088405 100644
--- a/hwaccess_physmap.c
+++ b/hwaccess_physmap.c
@@ -24,7 +24,7 @@
 #include <string.h>
 #include <errno.h>
 #include "flash.h"
-#include "hwaccess.h"
+#include "platform.h"
 #include "hwaccess_physmap.h"
 
 #if !defined(__DJGPP__) && !defined(__LIBPAYLOAD__)
diff --git a/meson.build b/meson.build
index e68f8a4..2ccb012 100644
--- a/meson.build
+++ b/meson.build
@@ -133,11 +133,11 @@
 endif
 
 if host_machine.endian() == 'little'
-  srcs += 'hwaccess_endian_little.c'
+  srcs += 'platform/endian_little.c'
   add_project_arguments('-D__FLASHROM_LITTLE_ENDIAN__=1', language : 'c')
 endif
 if host_machine.endian() == 'big'
-  srcs += 'hwaccess_endian_big.c'
+  srcs += 'platform/endian_big.c'
   add_project_arguments('-D__FLASHROM_BIG_ENDIAN__=1', language : 'c')
 endif
 
diff --git a/hwaccess.h b/platform.h
similarity index 94%
rename from hwaccess.h
rename to platform.h
index 4f7458a..f149f69 100644
--- a/hwaccess.h
+++ b/platform.h
@@ -16,11 +16,11 @@
  */
 
 /*
- * Header file for hardware access and OS abstraction. Included from flash.h.
+ * Header file for platform abstraction.
  */
 
-#ifndef __HWACCESS_H__
-#define __HWACCESS_H__ 1
+#ifndef __PLATFORM_H__
+#define __PLATFORM_H__ 1
 
 #include <stdint.h>
 
@@ -101,4 +101,4 @@
 uint32_t be_to_cpu32(uint32_t value);
 uint64_t be_to_cpu64(uint64_t value);
 
-#endif /* !__HWACCESS_H__ */
+#endif /* !__PLATFORM_H__ */
diff --git a/hwaccess_endian_big.c b/platform/endian_big.c
similarity index 97%
rename from hwaccess_endian_big.c
rename to platform/endian_big.c
index 1f7b5a3..5d65500 100644
--- a/hwaccess_endian_big.c
+++ b/platform/endian_big.c
@@ -15,7 +15,7 @@
  * GNU General Public License for more details.
  */
 
-#include "hwaccess.h"
+#include "../platform.h"
 
 /* convert cpu native endian to little endian */
 ___return_swapped(cpu_to_le, 8)
diff --git a/hwaccess_endian_little.c b/platform/endian_little.c
similarity index 97%
rename from hwaccess_endian_little.c
rename to platform/endian_little.c
index c0b493f..b7c0068 100644
--- a/hwaccess_endian_little.c
+++ b/platform/endian_little.c
@@ -15,7 +15,7 @@
  * GNU General Public License for more details.
  */
 
-#include "hwaccess.h"
+#include "../platform.h"
 
 /* convert cpu native endian to little endian */
 ___return_same(cpu_to_le, 8)