iPXE
linux_uaccess.h
Go to the documentation of this file.
1#ifndef _IPXE_LINUX_UACCESS_H
2#define _IPXE_LINUX_UACCESS_H
3
4/** @file
5 *
6 * iPXE user access API for Linux
7 *
8 * We have no concept of the underlying physical addresses, since
9 * these are not exposed to userspace. We provide a stub
10 * implementation of virt_to_phys() since this is required by the heap
11 * allocator to determine physical address alignment. We provide a
12 * matching stub implementation of phys_to_virt().
13 */
14
15FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
16FILE_SECBOOT ( PERMITTED );
17
18#ifdef UACCESS_LINUX
19#define UACCESS_PREFIX_linux
20#else
21#define UACCESS_PREFIX_linux __linux_
22#endif
23
24/**
25 * Convert virtual address to physical address
26 *
27 * @v virt Virtual address
28 * @ret phys Physical address
29 */
30static inline __always_inline physaddr_t
31UACCESS_INLINE ( linux, virt_to_phys ) ( volatile const void *virt ) {
32
33 /* We do not know the real underlying physical address. We
34 * provide this stub implementation only because it is
35 * required in order to allocate memory with a specified
36 * physical address alignment. We assume that the low-order
37 * bits of virtual addresses match the low-order bits of
38 * physical addresses, and so simply returning the virtual
39 * address will suffice for the purpose of determining
40 * alignment.
41 */
42 return ( ( physaddr_t ) virt );
43}
44
45/**
46 * Convert physical address to virtual address
47 *
48 * @v phys Physical address
49 * @ret virt Virtual address
50 */
51static inline __always_inline void *
52UACCESS_INLINE ( linux, phys_to_virt ) ( physaddr_t phys ) {
53
54 /* For symmetry with the stub virt_to_phys() */
55 return ( ( void * ) phys );
56}
57
58#endif /* _IPXE_LINUX_UACCESS_H */
unsigned long physaddr_t
Definition stdint.h:20
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 UACCESS_INLINE(_subsys, _api_func)
Calculate static inline user access API function name.
Definition uaccess.h:31