iPXE
dummy_pio.h
Go to the documentation of this file.
1 #ifndef _IPXE_DUMMY_PIO_H
2 #define _IPXE_DUMMY_PIO_H
3 
4 /** @file
5  *
6  * Dummy PIO reads and writes up to 32 bits
7  *
8  * There is no common standard for I/O-space access for non-x86 CPU
9  * families, and non-MMIO peripherals are vanishingly rare. Provide
10  * dummy implementations that will allow code to link and should cause
11  * drivers to simply fail to detect hardware at runtime.
12  */
13 
14 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15 
16 #include <string.h>
17 
18 #define DUMMY_INX( _prefix, _suffix, _type ) \
19 static inline __always_inline _type \
20 IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \
21  return ~( (_type) 0 ); \
22 } \
23 static inline __always_inline void \
24 IOAPI_INLINE ( _prefix, ins ## _suffix ) ( volatile _type *io_addr __unused, \
25  _type *data, unsigned int count ) {\
26  memset ( data, 0xff, count * sizeof ( *data ) ); \
27 }
28 
29 #define DUMMY_OUTX( _prefix, _suffix, _type ) \
30 static inline __always_inline void \
31 IOAPI_INLINE ( _prefix, out ## _suffix ) ( _type data __unused, \
32  volatile _type *io_addr __unused ){\
33  /* Do nothing */ \
34 } \
35 static inline __always_inline void \
36 IOAPI_INLINE ( _prefix, outs ## _suffix ) ( volatile _type *io_addr __unused, \
37  const _type *data __unused, \
38  unsigned int count __unused ) { \
39  /* Do nothing */ \
40 }
41 
42 #define DUMMY_IOREADX( _prefix, _width, _suffix, _type ) \
43 static inline __always_inline _type \
44 IOAPI_INLINE ( _prefix, ioread ## _width ) ( volatile _type *io_addr ) { \
45  return IOAPI_INLINE ( _prefix, read ## _suffix ) ( io_addr ); \
46 }
47 
48 #define DUMMY_IOWRITEX( _prefix, _width, _suffix, _type ) \
49 static inline __always_inline void \
50 IOAPI_INLINE ( _prefix, iowrite ## _width ) ( _type data, \
51  volatile _type *io_addr ) { \
52  IOAPI_INLINE ( _prefix, write ## _suffix ) ( data, io_addr ); \
53 }
54 
55 #define DUMMY_IODELAY( _prefix ) \
56 static inline __always_inline void \
57 IOAPI_INLINE ( _prefix, iodelay ) ( void ) { \
58  /* Nothing to do */ \
59 }
60 
61 #define DUMMY_PIO( _prefix ) \
62  DUMMY_INX ( _prefix, b, uint8_t ); \
63  DUMMY_INX ( _prefix, w, uint16_t ); \
64  DUMMY_INX ( _prefix, l, uint32_t ); \
65  DUMMY_OUTX ( _prefix, b, uint8_t ); \
66  DUMMY_OUTX ( _prefix, w, uint16_t ); \
67  DUMMY_OUTX ( _prefix, l, uint32_t ); \
68  DUMMY_IOREADX ( _prefix, 8, b, uint8_t ); \
69  DUMMY_IOREADX ( _prefix, 16, w, uint16_t ); \
70  DUMMY_IOREADX ( _prefix, 32, l, uint32_t ); \
71  DUMMY_IOWRITEX ( _prefix, 8, b, uint8_t ); \
72  DUMMY_IOWRITEX ( _prefix, 16, w, uint16_t ); \
73  DUMMY_IOWRITEX ( _prefix, 32, l, uint32_t ); \
74  DUMMY_IODELAY ( _prefix );
75 
76 #define PROVIDE_DUMMY_PIO( _prefix ) \
77  PROVIDE_IOAPI_INLINE ( _prefix, inb ); \
78  PROVIDE_IOAPI_INLINE ( _prefix, inw ); \
79  PROVIDE_IOAPI_INLINE ( _prefix, inl ); \
80  PROVIDE_IOAPI_INLINE ( _prefix, outb ); \
81  PROVIDE_IOAPI_INLINE ( _prefix, outw ); \
82  PROVIDE_IOAPI_INLINE ( _prefix, outl ); \
83  PROVIDE_IOAPI_INLINE ( _prefix, ioread8 ); \
84  PROVIDE_IOAPI_INLINE ( _prefix, ioread16 ); \
85  PROVIDE_IOAPI_INLINE ( _prefix, ioread32 ); \
86  PROVIDE_IOAPI_INLINE ( _prefix, iowrite8 ); \
87  PROVIDE_IOAPI_INLINE ( _prefix, iowrite16 ); \
88  PROVIDE_IOAPI_INLINE ( _prefix, iowrite32 ); \
89  PROVIDE_IOAPI_INLINE ( _prefix, iodelay );
90 
91 #endif /* _IPXE_DUMMY_PIO_H */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
String functions.