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

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