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
11FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12FILE_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
53static inline __always_inline void *
54UACCESS_INLINE ( flat, phys_to_virt ) ( physaddr_t phys ) {
55 return ( ( void * ) phys );
56}
57
58static inline __always_inline physaddr_t
59UACCESS_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 */
77virt_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 */
87void * __attribute__ (( const )) phys_to_virt ( physaddr_t phys );
88
89#endif /* _IPXE_UACCESS_H */
iPXE internal APIs
unsigned long physaddr_t
Definition stdint.h:20
Dummy architecture-specific user access API implementations.
static signed char phys[4]
Definition epic100.c:88
#define __always_inline
Declare a function to be always inline.
Definition compiler.h:611
#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
#define __attribute__(x)
Definition compiler.h:10
I/O API configuration.
#define UACCESS_INLINE(_subsys, _api_func)
Calculate static inline user access API function name.
Definition uaccess.h:31
Virtual offset memory model.
iPXE user access API for Linux