Blame SOURCES/0001-arm-Provide-dummy-implementation-for-in-out-s-b-w-l.patch

8b63a8
From c2226b3d1a4d9fc1daeb8dc6b9034d1fb46c1308 Mon Sep 17 00:00:00 2001
8b63a8
From: Michael Brown <mcb30@ipxe.org>
8b63a8
Date: Sun, 14 Jul 2019 15:27:01 +0100
8b63a8
Subject: [PATCH] [arm] Provide dummy implementations for {in,out}[s]{b,w,l}
8b63a8
8b63a8
It is currently not possible to build the all-drivers iPXE binaries
8b63a8
for ARM, since there is no implementation for inb(), outb(), etc.
8b63a8
8b63a8
There is no common standard for accessing I/O space on ARM platforms,
8b63a8
and there are almost no ARM-compatible peripherals that actually
8b63a8
require I/O space accesses.
8b63a8
8b63a8
Provide dummy implementations that behave as though no device is
8b63a8
present (i.e. ignore writes, return all bits high for reads).  This is
8b63a8
sufficient to allow the all-drivers binaries to link, and should cause
8b63a8
drivers to behave as though no I/O space peripherals are present in
8b63a8
the system.
8b63a8
8b63a8
Signed-off-by: Michael Brown <mcb30@ipxe.org>
8b63a8
---
8b63a8
 src/arch/arm/include/ipxe/arm_io.h | 77 +++++++++++++++++++++++-------
8b63a8
 1 file changed, 59 insertions(+), 18 deletions(-)
8b63a8
8b63a8
diff --git a/src/arch/arm/include/ipxe/arm_io.h b/src/arch/arm/include/ipxe/arm_io.h
8b63a8
index f8765af752..105f22bfbf 100644
8b63a8
--- a/src/arch/arm/include/ipxe/arm_io.h
8b63a8
+++ b/src/arch/arm/include/ipxe/arm_io.h
8b63a8
@@ -43,42 +43,83 @@ IOAPI_INLINE ( arm, bus_to_phys ) ( unsigned long bus_addr ) {
8b63a8
  *
8b63a8
  */
8b63a8
 
8b63a8
-#define ARM_READX( _api_func, _type, _insn_suffix, _reg_prefix )	      \
8b63a8
+#define ARM_READX( _suffix, _type, _insn_suffix, _reg_prefix )		      \
8b63a8
 static inline __always_inline _type					      \
8b63a8
-IOAPI_INLINE ( arm, _api_func ) ( volatile _type *io_addr ) {		      \
8b63a8
+IOAPI_INLINE ( arm, read ## _suffix ) ( volatile _type *io_addr ) {	      \
8b63a8
 	_type data;							      \
8b63a8
 	__asm__ __volatile__ ( "ldr" _insn_suffix " %" _reg_prefix "0, %1"    \
8b63a8
 			       : "=r" ( data ) : "Qo" ( *io_addr ) );	      \
8b63a8
 	return data;							      \
8b63a8
 }
8b63a8
 #ifdef __aarch64__
8b63a8
-ARM_READX ( readb, uint8_t, "b", "w" );
8b63a8
-ARM_READX ( readw, uint16_t, "h", "w" );
8b63a8
-ARM_READX ( readl, uint32_t, "", "w" );
8b63a8
-ARM_READX ( readq, uint64_t, "", "" );
8b63a8
+ARM_READX ( b, uint8_t, "b", "w" );
8b63a8
+ARM_READX ( w, uint16_t, "h", "w" );
8b63a8
+ARM_READX ( l, uint32_t, "", "w" );
8b63a8
+ARM_READX ( q, uint64_t, "", "" );
8b63a8
 #else
8b63a8
-ARM_READX ( readb, uint8_t, "b", "" );
8b63a8
-ARM_READX ( readw, uint16_t, "h", "" );
8b63a8
-ARM_READX ( readl, uint32_t, "", "" );
8b63a8
+ARM_READX ( b, uint8_t, "b", "" );
8b63a8
+ARM_READX ( w, uint16_t, "h", "" );
8b63a8
+ARM_READX ( l, uint32_t, "", "" );
8b63a8
 #endif
8b63a8
 
8b63a8
-#define ARM_WRITEX( _api_func, _type, _insn_suffix, _reg_prefix )			\
8b63a8
+#define ARM_WRITEX( _suffix, _type, _insn_suffix, _reg_prefix )		      \
8b63a8
 static inline __always_inline void					      \
8b63a8
-IOAPI_INLINE ( arm, _api_func ) ( _type data, volatile _type *io_addr ) {     \
8b63a8
+IOAPI_INLINE ( arm, write ## _suffix ) ( _type data,			      \
8b63a8
+					 volatile _type *io_addr ) {	      \
8b63a8
 	__asm__ __volatile__ ( "str" _insn_suffix " %" _reg_prefix "0, %1"    \
8b63a8
 			       : : "r" ( data ), "Qo" ( *io_addr ) );	      \
8b63a8
 }
8b63a8
 #ifdef __aarch64__
8b63a8
-ARM_WRITEX ( writeb, uint8_t, "b", "w" );
8b63a8
-ARM_WRITEX ( writew, uint16_t, "h", "w" );
8b63a8
-ARM_WRITEX ( writel, uint32_t, "", "w" );
8b63a8
-ARM_WRITEX ( writeq, uint64_t, "", "" );
8b63a8
+ARM_WRITEX ( b, uint8_t, "b", "w" );
8b63a8
+ARM_WRITEX ( w, uint16_t, "h", "w" );
8b63a8
+ARM_WRITEX ( l, uint32_t, "", "w" );
8b63a8
+ARM_WRITEX ( q, uint64_t, "", "" );
8b63a8
 #else
8b63a8
-ARM_WRITEX ( writeb, uint8_t, "b", "" );
8b63a8
-ARM_WRITEX ( writew, uint16_t, "h", "" );
8b63a8
-ARM_WRITEX ( writel, uint32_t, "", "" );
8b63a8
+ARM_WRITEX ( b, uint8_t, "b", "" );
8b63a8
+ARM_WRITEX ( w, uint16_t, "h", "" );
8b63a8
+ARM_WRITEX ( l, uint32_t, "", "" );
8b63a8
 #endif
8b63a8
 
8b63a8
+/*
8b63a8
+ * Dummy PIO reads and writes up to 32 bits
8b63a8
+ *
8b63a8
+ * There is no common standard for I/O-space access for ARM, and
8b63a8
+ * non-MMIO peripherals are vanishingly rare.  Provide dummy
8b63a8
+ * implementations that will allow code to link and should cause
8b63a8
+ * drivers to simply fail to detect hardware at runtime.
8b63a8
+ *
8b63a8
+ */
8b63a8
+
8b63a8
+#define ARM_INX( _suffix, _type )					      \
8b63a8
+static inline __always_inline _type					      \
8b63a8
+IOAPI_INLINE ( arm, in ## _suffix ) ( volatile _type *io_addr __unused) {     \
8b63a8
+	return ~( (_type) 0 );						      \
8b63a8
+}									      \
8b63a8
+static inline __always_inline void					      \
8b63a8
+IOAPI_INLINE ( arm, ins ## _suffix ) ( volatile _type *io_addr __unused,      \
8b63a8
+				       _type *data, unsigned int count ) {    \
8b63a8
+	memset ( data, 0xff, count * sizeof ( *data ) );		      \
8b63a8
+}
8b63a8
+ARM_INX ( b, uint8_t );
8b63a8
+ARM_INX ( w, uint16_t );
8b63a8
+ARM_INX ( l, uint32_t );
8b63a8
+
8b63a8
+#define ARM_OUTX( _suffix, _type )					      \
8b63a8
+static inline __always_inline void					      \
8b63a8
+IOAPI_INLINE ( arm, out ## _suffix ) ( _type data __unused,		      \
8b63a8
+				       volatile _type *io_addr __unused ) {   \
8b63a8
+	/* Do nothing */						      \
8b63a8
+}									      \
8b63a8
+static inline __always_inline void					      \
8b63a8
+IOAPI_INLINE ( arm, outs ## _suffix ) ( volatile _type *io_addr __unused,     \
8b63a8
+					const _type *data __unused,	      \
8b63a8
+					unsigned int count __unused ) {	      \
8b63a8
+	/* Do nothing */						      \
8b63a8
+}
8b63a8
+ARM_OUTX ( b, uint8_t );
8b63a8
+ARM_OUTX ( w, uint16_t );
8b63a8
+ARM_OUTX ( l, uint32_t );
8b63a8
+
8b63a8
 /*
8b63a8
  * Slow down I/O
8b63a8
  *