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

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