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 #define DUMMY_INX( _prefix, _suffix, _type ) \
17 static inline __always_inline _type \
18 IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \
19  return ~( (_type) 0 ); \
20 } \
21 static inline __always_inline void \
22 IOAPI_INLINE ( _prefix, ins ## _suffix ) ( volatile _type *io_addr __unused, \
23  _type *data, unsigned int count ) {\
24  memset ( data, 0xff, count * sizeof ( *data ) ); \
25 }
26 
27 #define DUMMY_OUTX( _prefix, _suffix, _type ) \
28 static inline __always_inline void \
29 IOAPI_INLINE ( _prefix, out ## _suffix ) ( _type data __unused, \
30  volatile _type *io_addr __unused ){\
31  /* Do nothing */ \
32 } \
33 static inline __always_inline void \
34 IOAPI_INLINE ( _prefix, outs ## _suffix ) ( volatile _type *io_addr __unused, \
35  const _type *data __unused, \
36  unsigned int count __unused ) { \
37  /* Do nothing */ \
38 }
39 
40 #define DUMMY_IODELAY( _prefix ) \
41 static inline __always_inline void \
42 IOAPI_INLINE ( _prefix, iodelay ) ( void ) { \
43  /* Nothing to do */ \
44 }
45 
46 #define DUMMY_PIO( _prefix ) \
47  DUMMY_INX ( _prefix, b, uint8_t ); \
48  DUMMY_INX ( _prefix, w, uint16_t ); \
49  DUMMY_INX ( _prefix, l, uint32_t ); \
50  DUMMY_OUTX ( _prefix, b, uint8_t ); \
51  DUMMY_OUTX ( _prefix, w, uint16_t ); \
52  DUMMY_OUTX ( _prefix, l, uint32_t ); \
53  DUMMY_IODELAY ( _prefix );
54 
55 #define PROVIDE_DUMMY_PIO( _prefix ) \
56  PROVIDE_IOAPI_INLINE ( _prefix, inb ); \
57  PROVIDE_IOAPI_INLINE ( _prefix, inw ); \
58  PROVIDE_IOAPI_INLINE ( _prefix, inl ); \
59  PROVIDE_IOAPI_INLINE ( _prefix, outb ); \
60  PROVIDE_IOAPI_INLINE ( _prefix, outw ); \
61  PROVIDE_IOAPI_INLINE ( _prefix, outl ); \
62  PROVIDE_IOAPI_INLINE ( _prefix, iodelay );
63 
64 #endif /* _IPXE_DUMMY_PIO_H */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)