]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ioapi] Centralise definitions for dummy PIO
authorMichael Brown <mcb30@ipxe.org>
Thu, 29 Jun 2023 14:08:23 +0000 (15:08 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 29 Jun 2023 14:40:24 +0000 (15:40 +0100)
There is no common standard for I/O-space access for non-x86 CPU
families, and non-MMIO peripherals are vanishingly rare.

Generalise the existing ARM definitions for dummy PIO to allow for
reuse by other CPU architectures.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/arm/core/arm_io.c
src/arch/arm/include/ipxe/arm_io.h
src/include/ipxe/dummy_pio.h [new file with mode: 0644]

index f8022715a683597f6950938f033af6e2593d359c..41b42389a16e89926fb603da57ba03b215443d84 100644 (file)
@@ -83,7 +83,6 @@ PROVIDE_IOAPI_INLINE ( arm, readl );
 PROVIDE_IOAPI_INLINE ( arm, writeb );
 PROVIDE_IOAPI_INLINE ( arm, writew );
 PROVIDE_IOAPI_INLINE ( arm, writel );
-PROVIDE_IOAPI_INLINE ( arm, iodelay );
 PROVIDE_IOAPI_INLINE ( arm, mb );
 #ifdef __aarch64__
 PROVIDE_IOAPI_INLINE ( arm, readq );
@@ -92,3 +91,4 @@ PROVIDE_IOAPI_INLINE ( arm, writeq );
 PROVIDE_IOAPI ( arm, readq, arm32_readq );
 PROVIDE_IOAPI ( arm, writeq, arm32_writeq );
 #endif
+PROVIDE_DUMMY_PIO ( arm );
index 046cbdb06bb764c0912c922b73912f73ecd8fc0d..7ed38993d51e6098eeea63543c676ed5113b754b 100644 (file)
@@ -15,6 +15,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define IOAPI_PREFIX_arm __arm_
 #endif
 
+#include <ipxe/dummy_pio.h>
+
 /*
  * Memory space mappings
  *
@@ -77,55 +79,6 @@ ARM_WRITEX ( w, uint16_t, "h", "" );
 ARM_WRITEX ( l, uint32_t, "", "" );
 #endif
 
-/*
- * Dummy PIO reads and writes up to 32 bits
- *
- * There is no common standard for I/O-space access for ARM, and
- * non-MMIO peripherals are vanishingly rare.  Provide dummy
- * implementations that will allow code to link and should cause
- * drivers to simply fail to detect hardware at runtime.
- *
- */
-
-#define ARM_INX( _suffix, _type )                                            \
-static inline __always_inline _type                                          \
-IOAPI_INLINE ( arm, in ## _suffix ) ( volatile _type *io_addr __unused) {     \
-       return ~( (_type) 0 );                                                \
-}                                                                            \
-static inline __always_inline void                                           \
-IOAPI_INLINE ( arm, ins ## _suffix ) ( volatile _type *io_addr __unused,      \
-                                      _type *data, unsigned int count ) {    \
-       memset ( data, 0xff, count * sizeof ( *data ) );                      \
-}
-ARM_INX ( b, uint8_t );
-ARM_INX ( w, uint16_t );
-ARM_INX ( l, uint32_t );
-
-#define ARM_OUTX( _suffix, _type )                                           \
-static inline __always_inline void                                           \
-IOAPI_INLINE ( arm, out ## _suffix ) ( _type data __unused,                  \
-                                      volatile _type *io_addr __unused ) {   \
-       /* Do nothing */                                                      \
-}                                                                            \
-static inline __always_inline void                                           \
-IOAPI_INLINE ( arm, outs ## _suffix ) ( volatile _type *io_addr __unused,     \
-                                       const _type *data __unused,           \
-                                       unsigned int count __unused ) {       \
-       /* Do nothing */                                                      \
-}
-ARM_OUTX ( b, uint8_t );
-ARM_OUTX ( w, uint16_t );
-ARM_OUTX ( l, uint32_t );
-
-/*
- * Slow down I/O
- *
- */
-static inline __always_inline void
-IOAPI_INLINE ( arm, iodelay ) ( void ) {
-       /* Nothing to do */
-}
-
 /*
  * Memory barrier
  *
@@ -140,4 +93,7 @@ IOAPI_INLINE ( arm, mb ) ( void ) {
 #endif
 }
 
+/* Dummy PIO */
+DUMMY_PIO ( arm );
+
 #endif /* _IPXE_ARM_IO_H */
diff --git a/src/include/ipxe/dummy_pio.h b/src/include/ipxe/dummy_pio.h
new file mode 100644 (file)
index 0000000..1cdabba
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef _IPXE_DUMMY_PIO_H
+#define _IPXE_DUMMY_PIO_H
+
+/** @file
+ *
+ * Dummy PIO reads and writes up to 32 bits
+ *
+ * There is no common standard for I/O-space access for non-x86 CPU
+ * families, and non-MMIO peripherals are vanishingly rare.  Provide
+ * dummy implementations that will allow code to link and should cause
+ * drivers to simply fail to detect hardware at runtime.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#define DUMMY_INX( _prefix, _suffix, _type )                                 \
+static inline __always_inline _type                                          \
+IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \
+       return ~( (_type) 0 );                                                \
+}                                                                            \
+static inline __always_inline void                                           \
+IOAPI_INLINE ( _prefix, ins ## _suffix ) ( volatile _type *io_addr __unused,  \
+                                          _type *data, unsigned int count ) {\
+       memset ( data, 0xff, count * sizeof ( *data ) );                      \
+}
+
+#define DUMMY_OUTX( _prefix, _suffix, _type )                                \
+static inline __always_inline void                                           \
+IOAPI_INLINE ( _prefix, out ## _suffix ) ( _type data __unused,                      \
+                                          volatile _type *io_addr __unused ){\
+       /* Do nothing */                                                      \
+}                                                                            \
+static inline __always_inline void                                           \
+IOAPI_INLINE ( _prefix, outs ## _suffix ) ( volatile _type *io_addr __unused, \
+                                           const _type *data __unused,       \
+                                           unsigned int count __unused ) {   \
+       /* Do nothing */                                                      \
+}
+
+#define DUMMY_IODELAY( _prefix )                                             \
+static inline __always_inline void                                           \
+IOAPI_INLINE ( _prefix, iodelay ) ( void ) {                                 \
+       /* Nothing to do */                                                   \
+}
+
+#define DUMMY_PIO( _prefix )                                                 \
+       DUMMY_INX ( _prefix, b, uint8_t );                                    \
+       DUMMY_INX ( _prefix, w, uint16_t );                                   \
+       DUMMY_INX ( _prefix, l, uint32_t );                                   \
+       DUMMY_OUTX ( _prefix, b, uint8_t );                                   \
+       DUMMY_OUTX ( _prefix, w, uint16_t );                                  \
+       DUMMY_OUTX ( _prefix, l, uint32_t );                                  \
+       DUMMY_IODELAY ( _prefix );
+
+#define PROVIDE_DUMMY_PIO( _prefix )                                         \
+       PROVIDE_IOAPI_INLINE ( _prefix, inb );                                \
+       PROVIDE_IOAPI_INLINE ( _prefix, inw );                                \
+       PROVIDE_IOAPI_INLINE ( _prefix, inl );                                \
+       PROVIDE_IOAPI_INLINE ( _prefix, outb );                               \
+       PROVIDE_IOAPI_INLINE ( _prefix, outw );                               \
+       PROVIDE_IOAPI_INLINE ( _prefix, outl );                               \
+       PROVIDE_IOAPI_INLINE ( _prefix, iodelay );
+
+#endif /* _IPXE_DUMMY_PIO_H */