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 
15 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
16 
17 #ifdef UACCESS_LINUX
18 #define UACCESS_PREFIX_linux
19 #else
20 #define UACCESS_PREFIX_linux __linux_
21 #endif
22 
23 /**
24  * Convert virtual address to physical address
25  *
26  * @v virt Virtual address
27  * @ret phys Physical address
28  */
29 static inline __always_inline physaddr_t
30 UACCESS_INLINE ( linux, virt_to_phys ) ( volatile const void *virt ) {
31 
32  /* We do not know the real underlying physical address. We
33  * provide this stub implementation only because it is
34  * required in order to allocate memory with a specified
35  * physical address alignment. We assume that the low-order
36  * bits of virtual addresses match the low-order bits of
37  * physical addresses, and so simply returning the virtual
38  * address will suffice for the purpose of determining
39  * alignment.
40  */
41  return ( ( physaddr_t ) virt );
42 }
43 
44 /**
45  * Convert physical address to virtual address
46  *
47  * @v phys Physical address
48  * @ret virt Virtual address
49  */
50 static inline __always_inline void *
51 UACCESS_INLINE ( linux, phys_to_virt ) ( physaddr_t phys ) {
52 
53  /* For symmetry with the stub virt_to_phys() */
54  return ( ( void * ) phys );
55 }
56 
57 #endif /* _IPXE_LINUX_UACCESS_H */
static signed char phys[4]
Definition: epic100.c:88
static __always_inline physaddr_t UACCESS_INLINE(linux, virt_to_phys)(volatile const void *virt)
Convert virtual address to physical address.
Definition: linux_uaccess.h:30
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
unsigned long physaddr_t
Definition: stdint.h:20