iPXE
api.h
Go to the documentation of this file.
1 #ifndef _IPXE_API_H
2 #define _IPXE_API_H
3 
4 /** @file
5  *
6  * iPXE internal APIs
7  *
8  * There are various formally-defined APIs internal to iPXE, with
9  * several differing implementations specific to particular execution
10  * environments (e.g. PC BIOS, EFI, LinuxBIOS).
11  *
12  */
13 
14 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15 FILE_SECBOOT ( PERMITTED );
16 
17 /** @defgroup Single-implementation APIs
18  *
19  * These are APIs for which only a single implementation may be
20  * compiled in at any given time.
21  *
22  * @{
23  */
24 
25 /**
26  * Calculate function implementation name
27  *
28  * @v _prefix Subsystem prefix
29  * @v _api_func API function
30  * @ret _subsys_func Subsystem API function
31  *
32  * The subsystem prefix should be an empty string for the currently
33  * selected subsystem, and should be a subsystem-unique string for all
34  * other subsystems.
35  */
36 #define SINGLE_API_NAME( _prefix, _api_func ) _prefix ## _api_func
37 
38 /**
39  * Calculate static inline function name
40  *
41  * @v _prefix Subsystem prefix
42  * @v _api_func API function
43  * @ret _subsys_func Subsystem API function
44  */
45 #define SINGLE_API_INLINE( _prefix, _api_func ) \
46  SINGLE_API_NAME ( _prefix, _api_func )
47 
48 /**
49  * Provide an API implementation
50  *
51  * @v _prefix Subsystem prefix
52  * @v _api_func API function
53  * @v _func Implementing function
54  */
55 #define PROVIDE_SINGLE_API( _prefix, _api_func, _func ) \
56  /* Ensure that _api_func exists */ \
57  typeof ( _api_func ) _api_func; \
58  /* Ensure that _func exists */ \
59  typeof ( _func ) _func; \
60  /* Ensure that _func is type-compatible with _api_func */ \
61  typeof ( _api_func ) _func; \
62  /* Ensure that _subsys_func is non-static */ \
63  extern typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func ); \
64  /* Provide symbol alias from _subsys_func to _func */ \
65  typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func ) \
66  __attribute__ (( alias ( #_func ) ));
67 
68 /**
69  * Provide a static inline API implementation
70  *
71  * @v _prefix Subsystem prefix
72  * @v _api_func API function
73  */
74 #define PROVIDE_SINGLE_API_INLINE( _prefix, _api_func ) \
75  /* Ensure that _api_func exists */ \
76  typeof ( _api_func ) _api_func; \
77  /* Ensure that _subsys_func exists and is static */ \
78  static typeof ( SINGLE_API_INLINE ( _prefix, _api_func ) ) \
79  SINGLE_API_INLINE ( _prefix, _api_func ); \
80  /* Ensure that _subsys_func is type-compatible with _api_func */ \
81  typeof ( _api_func ) SINGLE_API_INLINE ( _prefix, _api_func );
82 
83 /** @} */
84 
85 #endif /* _IPXE_API_H */
FILE_SECBOOT(PERMITTED)
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)