Browse Source

[arm] Provide dummy implementations for {in,out}[s]{b,w,l}

It is currently not possible to build the all-drivers iPXE binaries
for ARM, since there is no implementation for inb(), outb(), etc.

There is no common standard for accessing I/O space on ARM platforms,
and there are almost no ARM-compatible peripherals that actually
require I/O space accesses.

Provide dummy implementations that behave as though no device is
present (i.e. ignore writes, return all bits high for reads).  This is
sufficient to allow the all-drivers binaries to link, and should cause
drivers to behave as though no I/O space peripherals are present in
the system.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 5 years ago
parent
commit
c2226b3d1a
1 changed files with 59 additions and 18 deletions
  1. 59
    18
      src/arch/arm/include/ipxe/arm_io.h

+ 59
- 18
src/arch/arm/include/ipxe/arm_io.h View File

@@ -43,42 +43,83 @@ IOAPI_INLINE ( arm, bus_to_phys ) ( unsigned long bus_addr ) {
43 43
  *
44 44
  */
45 45
 
46
-#define ARM_READX( _api_func, _type, _insn_suffix, _reg_prefix )	      \
46
+#define ARM_READX( _suffix, _type, _insn_suffix, _reg_prefix )		      \
47 47
 static inline __always_inline _type					      \
48
-IOAPI_INLINE ( arm, _api_func ) ( volatile _type *io_addr ) {		      \
48
+IOAPI_INLINE ( arm, read ## _suffix ) ( volatile _type *io_addr ) {	      \
49 49
 	_type data;							      \
50 50
 	__asm__ __volatile__ ( "ldr" _insn_suffix " %" _reg_prefix "0, %1"    \
51 51
 			       : "=r" ( data ) : "Qo" ( *io_addr ) );	      \
52 52
 	return data;							      \
53 53
 }
54 54
 #ifdef __aarch64__
55
-ARM_READX ( readb, uint8_t, "b", "w" );
56
-ARM_READX ( readw, uint16_t, "h", "w" );
57
-ARM_READX ( readl, uint32_t, "", "w" );
58
-ARM_READX ( readq, uint64_t, "", "" );
55
+ARM_READX ( b, uint8_t, "b", "w" );
56
+ARM_READX ( w, uint16_t, "h", "w" );
57
+ARM_READX ( l, uint32_t, "", "w" );
58
+ARM_READX ( q, uint64_t, "", "" );
59 59
 #else
60
-ARM_READX ( readb, uint8_t, "b", "" );
61
-ARM_READX ( readw, uint16_t, "h", "" );
62
-ARM_READX ( readl, uint32_t, "", "" );
60
+ARM_READX ( b, uint8_t, "b", "" );
61
+ARM_READX ( w, uint16_t, "h", "" );
62
+ARM_READX ( l, uint32_t, "", "" );
63 63
 #endif
64 64
 
65
-#define ARM_WRITEX( _api_func, _type, _insn_suffix, _reg_prefix )			\
65
+#define ARM_WRITEX( _suffix, _type, _insn_suffix, _reg_prefix )		      \
66 66
 static inline __always_inline void					      \
67
-IOAPI_INLINE ( arm, _api_func ) ( _type data, volatile _type *io_addr ) {     \
67
+IOAPI_INLINE ( arm, write ## _suffix ) ( _type data,			      \
68
+					 volatile _type *io_addr ) {	      \
68 69
 	__asm__ __volatile__ ( "str" _insn_suffix " %" _reg_prefix "0, %1"    \
69 70
 			       : : "r" ( data ), "Qo" ( *io_addr ) );	      \
70 71
 }
71 72
 #ifdef __aarch64__
72
-ARM_WRITEX ( writeb, uint8_t, "b", "w" );
73
-ARM_WRITEX ( writew, uint16_t, "h", "w" );
74
-ARM_WRITEX ( writel, uint32_t, "", "w" );
75
-ARM_WRITEX ( writeq, uint64_t, "", "" );
73
+ARM_WRITEX ( b, uint8_t, "b", "w" );
74
+ARM_WRITEX ( w, uint16_t, "h", "w" );
75
+ARM_WRITEX ( l, uint32_t, "", "w" );
76
+ARM_WRITEX ( q, uint64_t, "", "" );
76 77
 #else
77
-ARM_WRITEX ( writeb, uint8_t, "b", "" );
78
-ARM_WRITEX ( writew, uint16_t, "h", "" );
79
-ARM_WRITEX ( writel, uint32_t, "", "" );
78
+ARM_WRITEX ( b, uint8_t, "b", "" );
79
+ARM_WRITEX ( w, uint16_t, "h", "" );
80
+ARM_WRITEX ( l, uint32_t, "", "" );
80 81
 #endif
81 82
 
83
+/*
84
+ * Dummy PIO reads and writes up to 32 bits
85
+ *
86
+ * There is no common standard for I/O-space access for ARM, and
87
+ * non-MMIO peripherals are vanishingly rare.  Provide dummy
88
+ * implementations that will allow code to link and should cause
89
+ * drivers to simply fail to detect hardware at runtime.
90
+ *
91
+ */
92
+
93
+#define ARM_INX( _suffix, _type )					      \
94
+static inline __always_inline _type					      \
95
+IOAPI_INLINE ( arm, in ## _suffix ) ( volatile _type *io_addr __unused) {     \
96
+	return ~( (_type) 0 );						      \
97
+}									      \
98
+static inline __always_inline void					      \
99
+IOAPI_INLINE ( arm, ins ## _suffix ) ( volatile _type *io_addr __unused,      \
100
+				       _type *data, unsigned int count ) {    \
101
+	memset ( data, 0xff, count * sizeof ( *data ) );		      \
102
+}
103
+ARM_INX ( b, uint8_t );
104
+ARM_INX ( w, uint16_t );
105
+ARM_INX ( l, uint32_t );
106
+
107
+#define ARM_OUTX( _suffix, _type )					      \
108
+static inline __always_inline void					      \
109
+IOAPI_INLINE ( arm, out ## _suffix ) ( _type data __unused,		      \
110
+				       volatile _type *io_addr __unused ) {   \
111
+	/* Do nothing */						      \
112
+}									      \
113
+static inline __always_inline void					      \
114
+IOAPI_INLINE ( arm, outs ## _suffix ) ( volatile _type *io_addr __unused,     \
115
+					const _type *data __unused,	      \
116
+					unsigned int count __unused ) {	      \
117
+	/* Do nothing */						      \
118
+}
119
+ARM_OUTX ( b, uint8_t );
120
+ARM_OUTX ( w, uint16_t );
121
+ARM_OUTX ( l, uint32_t );
122
+
82 123
 /*
83 124
  * Slow down I/O
84 125
  *

Loading…
Cancel
Save