iPXE
uaccess.h
Go to the documentation of this file.
1 #ifndef _IPXE_UACCESS_H
2 #define _IPXE_UACCESS_H
3 
4 /**
5  * @file
6  *
7  * Access to external ("user") memory
8  *
9  */
10 
11 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12 FILE_SECBOOT ( PERMITTED );
13 
14 #include <stdint.h>
15 #include <ipxe/api.h>
16 #include <config/ioapi.h>
17 
18 #ifdef UACCESS_FLAT
19 #define UACCESS_PREFIX_flat
20 #else
21 #define UACCESS_PREFIX_flat __flat_
22 #endif
23 
24 /**
25  * Calculate static inline user access API function name
26  *
27  * @v _prefix Subsystem prefix
28  * @v _api_func API function
29  * @ret _subsys_func Subsystem API function
30  */
31 #define UACCESS_INLINE( _subsys, _api_func ) \
32  SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func )
33 
34 /**
35  * Provide an user access API implementation
36  *
37  * @v _prefix Subsystem prefix
38  * @v _api_func API function
39  * @v _func Implementing function
40  */
41 #define PROVIDE_UACCESS( _subsys, _api_func, _func ) \
42  PROVIDE_SINGLE_API ( UACCESS_PREFIX_ ## _subsys, _api_func, _func )
43 
44 /**
45  * Provide a static inline user access API implementation
46  *
47  * @v _prefix Subsystem prefix
48  * @v _api_func API function
49  */
50 #define PROVIDE_UACCESS_INLINE( _subsys, _api_func ) \
51  PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func )
52 
53 static inline __always_inline void *
54 UACCESS_INLINE ( flat, phys_to_virt ) ( physaddr_t phys ) {
55  return ( ( void * ) phys );
56 }
57 
58 static inline __always_inline physaddr_t
59 UACCESS_INLINE ( flat, virt_to_phys ) ( volatile const void *virt ) {
60  return ( ( physaddr_t ) virt );
61 }
62 
63 /* Include all architecture-independent user access API headers */
64 #include <ipxe/virt_offset.h>
66 
67 /* Include all architecture-dependent user access API headers */
68 #include <bits/uaccess.h>
69 
70 /**
71  * Convert virtual address to a physical address
72  *
73  * @v virt Virtual address
74  * @ret phys Physical address
75  */
76 physaddr_t __attribute__ (( const ))
77 virt_to_phys ( volatile const void *virt );
78 
79 /**
80  * Convert physical address to a virtual address
81  *
82  * @v phys Physical address
83  * @ret virt Virtual address
84  *
85  * This operation is not available under all memory models.
86  */
87 void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys );
88 
89 #endif /* _IPXE_UACCESS_H */
iPXE internal APIs
FILE_SECBOOT(PERMITTED)
iPXE user access API for Linux
Virtual offset memory model.
static signed char phys[4]
Definition: epic100.c:88
A 16-bit general register.
Definition: registers.h:24
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
#define UACCESS_INLINE(_subsys, _api_func)
Calculate static inline user access API function name.
Definition: uaccess.h:31
unsigned long physaddr_t
Definition: stdint.h:20
I/O API configuration.
physaddr_t __attribute__((const)) virt_to_phys(volatile const void *virt)
Convert virtual address to a physical address.
Dummy architecture-specific user access API implementations.