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
14FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15FILE_SECBOOT ( PERMITTED );
16
17#include <string.h>
18
19#define DUMMY_INX( _prefix, _suffix, _type ) \
20static inline __always_inline _type \
21IOAPI_INLINE ( _prefix, in ## _suffix ) ( volatile _type *io_addr __unused) { \
22 return ~( (_type) 0 ); \
23} \
24static inline __always_inline void \
25IOAPI_INLINE ( _prefix, ins ## _suffix ) ( volatile _type *io_addr __unused, \
26 _type *data, unsigned int count ) {\
27 memset ( data, 0xff, count * sizeof ( *data ) ); \
28}
29
30#define DUMMY_OUTX( _prefix, _suffix, _type ) \
31static inline __always_inline void \
32IOAPI_INLINE ( _prefix, out ## _suffix ) ( _type data __unused, \
33 volatile _type *io_addr __unused ){\
34 /* Do nothing */ \
35} \
36static inline __always_inline void \
37IOAPI_INLINE ( _prefix, outs ## _suffix ) ( volatile _type *io_addr __unused, \
38 const _type *data __unused, \
39 unsigned int count __unused ) { \
40 /* Do nothing */ \
41}
42
43#define DUMMY_IOREADX( _prefix, _width, _suffix, _type ) \
44static inline __always_inline _type \
45IOAPI_INLINE ( _prefix, ioread ## _width ) ( volatile _type *io_addr ) { \
46 return IOAPI_INLINE ( _prefix, read ## _suffix ) ( io_addr ); \
47}
48
49#define DUMMY_IOWRITEX( _prefix, _width, _suffix, _type ) \
50static inline __always_inline void \
51IOAPI_INLINE ( _prefix, iowrite ## _width ) ( _type data, \
52 volatile _type *io_addr ) { \
53 IOAPI_INLINE ( _prefix, write ## _suffix ) ( data, io_addr ); \
54}
55
56#define DUMMY_IODELAY( _prefix ) \
57static inline __always_inline void \
58IOAPI_INLINE ( _prefix, iodelay ) ( void ) { \
59 /* Nothing to do */ \
60}
61
62#define DUMMY_PIO( _prefix ) \
63 DUMMY_INX ( _prefix, b, uint8_t ); \
64 DUMMY_INX ( _prefix, w, uint16_t ); \
65 DUMMY_INX ( _prefix, l, uint32_t ); \
66 DUMMY_OUTX ( _prefix, b, uint8_t ); \
67 DUMMY_OUTX ( _prefix, w, uint16_t ); \
68 DUMMY_OUTX ( _prefix, l, uint32_t ); \
69 DUMMY_IOREADX ( _prefix, 8, b, uint8_t ); \
70 DUMMY_IOREADX ( _prefix, 16, w, uint16_t ); \
71 DUMMY_IOREADX ( _prefix, 32, l, uint32_t ); \
72 DUMMY_IOWRITEX ( _prefix, 8, b, uint8_t ); \
73 DUMMY_IOWRITEX ( _prefix, 16, w, uint16_t ); \
74 DUMMY_IOWRITEX ( _prefix, 32, l, uint32_t ); \
75 DUMMY_IODELAY ( _prefix );
76
77#define PROVIDE_DUMMY_PIO( _prefix ) \
78 PROVIDE_IOAPI_INLINE ( _prefix, inb ); \
79 PROVIDE_IOAPI_INLINE ( _prefix, inw ); \
80 PROVIDE_IOAPI_INLINE ( _prefix, inl ); \
81 PROVIDE_IOAPI_INLINE ( _prefix, outb ); \
82 PROVIDE_IOAPI_INLINE ( _prefix, outw ); \
83 PROVIDE_IOAPI_INLINE ( _prefix, outl ); \
84 PROVIDE_IOAPI_INLINE ( _prefix, ioread8 ); \
85 PROVIDE_IOAPI_INLINE ( _prefix, ioread16 ); \
86 PROVIDE_IOAPI_INLINE ( _prefix, ioread32 ); \
87 PROVIDE_IOAPI_INLINE ( _prefix, iowrite8 ); \
88 PROVIDE_IOAPI_INLINE ( _prefix, iowrite16 ); \
89 PROVIDE_IOAPI_INLINE ( _prefix, iowrite32 ); \
90 PROVIDE_IOAPI_INLINE ( _prefix, iodelay );
91
92#endif /* _IPXE_DUMMY_PIO_H */
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
String functions.