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 
13 #include <stdint.h>
14 #include <ipxe/api.h>
15 #include <config/ioapi.h>
16 
17 #ifdef UACCESS_FLAT
18 #define UACCESS_PREFIX_flat
19 #else
20 #define UACCESS_PREFIX_flat __flat_
21 #endif
22 
23 /**
24  * Calculate static inline user access API function name
25  *
26  * @v _prefix Subsystem prefix
27  * @v _api_func API function
28  * @ret _subsys_func Subsystem API function
29  */
30 #define UACCESS_INLINE( _subsys, _api_func ) \
31  SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func )
32 
33 /**
34  * Provide an user access API implementation
35  *
36  * @v _prefix Subsystem prefix
37  * @v _api_func API function
38  * @v _func Implementing function
39  */
40 #define PROVIDE_UACCESS( _subsys, _api_func, _func ) \
41  PROVIDE_SINGLE_API ( UACCESS_PREFIX_ ## _subsys, _api_func, _func )
42 
43 /**
44  * Provide a static inline user access API implementation
45  *
46  * @v _prefix Subsystem prefix
47  * @v _api_func API function
48  */
49 #define PROVIDE_UACCESS_INLINE( _subsys, _api_func ) \
50  PROVIDE_SINGLE_API_INLINE ( UACCESS_PREFIX_ ## _subsys, _api_func )
51 
52 static inline __always_inline void *
53 UACCESS_INLINE ( flat, phys_to_virt ) ( physaddr_t phys ) {
54  return ( ( void * ) phys );
55 }
56 
57 static inline __always_inline physaddr_t
58 UACCESS_INLINE ( flat, virt_to_phys ) ( volatile const void *virt ) {
59  return ( ( physaddr_t ) virt );
60 }
61 
62 /* Include all architecture-independent user access API headers */
63 #include <ipxe/virt_offset.h>
65 
66 /* Include all architecture-dependent user access API headers */
67 #include <bits/uaccess.h>
68 
69 /**
70  * Convert virtual address to a physical address
71  *
72  * @v virt Virtual address
73  * @ret phys Physical address
74  */
75 physaddr_t __attribute__ (( const ))
76 virt_to_phys ( volatile const void *virt );
77 
78 /**
79  * Convert physical address to a virtual address
80  *
81  * @v phys Physical address
82  * @ret virt Virtual address
83  *
84  * This operation is not available under all memory models.
85  */
86 void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys );
87 
88 #endif /* _IPXE_UACCESS_H */
iPXE internal APIs
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:30
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.