iPXE
efi_uaccess.h
Go to the documentation of this file.
1 #ifndef _IPXE_EFI_UACCESS_H
2 #define _IPXE_EFI_UACCESS_H
3 
4 /** @file
5  *
6  * iPXE user access API for EFI
7  *
8  * EFI runs with flat physical addressing, so the various mappings
9  * between virtual addresses, I/O addresses and bus addresses are all
10  * no-ops.
11  */
12 
13 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14 
15 #ifdef UACCESS_EFI
16 #define UACCESS_PREFIX_efi
17 #else
18 #define UACCESS_PREFIX_efi __efi_
19 #endif
20 
21 /**
22  * Convert physical address to user pointer
23  *
24  * @v phys_addr Physical address
25  * @ret userptr User pointer
26  */
27 static inline __always_inline userptr_t
28 UACCESS_INLINE ( efi, phys_to_user ) ( unsigned long phys_addr ) {
29  return phys_addr;
30 }
31 
32 /**
33  * Convert user buffer to physical address
34  *
35  * @v userptr User pointer
36  * @v offset Offset from user pointer
37  * @ret phys_addr Physical address
38  */
39 static inline __always_inline unsigned long
41  return ( userptr + offset );
42 }
43 
44 static inline __always_inline userptr_t
45 UACCESS_INLINE ( efi, virt_to_user ) ( volatile const void *addr ) {
46  return trivial_virt_to_user ( addr );
47 }
48 
49 static inline __always_inline void *
50 UACCESS_INLINE ( efi, user_to_virt ) ( userptr_t userptr, off_t offset ) {
51  return trivial_user_to_virt ( userptr, offset );
52 }
53 
54 static inline __always_inline userptr_t
55 UACCESS_INLINE ( efi, userptr_add ) ( userptr_t userptr, off_t offset ) {
56  return trivial_userptr_add ( userptr, offset );
57 }
58 
59 static inline __always_inline off_t
60 UACCESS_INLINE ( efi, userptr_sub ) ( userptr_t userptr,
62  return trivial_userptr_sub ( userptr, subtrahend );
63 }
64 
65 static inline __always_inline void
68  size_t len ) {
70 }
71 
72 static inline __always_inline void
75  size_t len ) {
77 }
78 
79 static inline __always_inline int
82  size_t len ) {
84 }
85 
86 static inline __always_inline void
88  int c, size_t len ) {
90 }
91 
92 static inline __always_inline size_t
94  return trivial_strlen_user ( buffer, offset );
95 }
96 
97 static inline __always_inline off_t
99  int c, size_t len ) {
100  return trivial_memchr_user ( buffer, offset, c, len );
101 }
102 
103 #endif /* _IPXE_EFI_UACCESS_H */
static __always_inline void off_t userptr_t off_t src_off
Definition: efi_uaccess.h:66
static __always_inline size_t trivial_strlen_user(userptr_t buffer, off_t offset)
Find length of NUL-terminated string in user buffer.
Definition: uaccess.h:167
static __always_inline int trivial_memcmp_user(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
Compare data between user buffers.
Definition: uaccess.h:140
static __always_inline void * trivial_user_to_virt(userptr_t userptr, off_t offset)
Convert user pointer to virtual address.
Definition: uaccess.h:69
off_t memchr_user(userptr_t userptr, off_t offset, int c, size_t len)
Find character in user buffer.
static __always_inline int off_t userptr_t second
Definition: efi_uaccess.h:80
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
static __always_inline void off_t dest_off
Definition: efi_uaccess.h:66
static __always_inline userptr_t trivial_userptr_add(userptr_t userptr, off_t offset)
Add offset to user pointer.
Definition: uaccess.h:81
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
static __always_inline void trivial_memmove_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers, allowing for overlap.
Definition: uaccess.h:123
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
static __always_inline off_t trivial_memchr_user(userptr_t buffer, off_t offset, int c, size_t len)
Find character in user buffer.
Definition: uaccess.h:181
static __always_inline off_t userptr_t subtrahend
Definition: efi_uaccess.h:61
off_t userptr_sub(userptr_t userptr, userptr_t subtrahend)
Subtract user pointers.
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
userptr_t userptr_add(userptr_t userptr, off_t offset)
Add offset to user pointer.
static __always_inline void off_t userptr_t off_t size_t len
Definition: efi_uaccess.h:68
static __always_inline int off_t userptr_t off_t second_off
Definition: efi_uaccess.h:80
static void * dest
Definition: strings.h:176
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
#define __always_inline
Declare a function to be always inline.
Definition: compiler.h:611
u32 addr
Definition: sky2.h:8
static __always_inline userptr_t UACCESS_INLINE(efi, phys_to_user)(unsigned long phys_addr)
Convert physical address to user pointer.
Definition: efi_uaccess.h:28
static __always_inline off_t trivial_userptr_sub(userptr_t userptr, userptr_t subtrahend)
Subtract user pointers.
Definition: uaccess.h:93
size_t strlen_user(userptr_t userptr, off_t offset)
Find length of NUL-terminated string in user buffer.
signed long off_t
Definition: stdint.h:8
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static __always_inline int off_t first_off
Definition: efi_uaccess.h:80
int memcmp_user(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
Compare data between user buffers.
static __always_inline void trivial_memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
Definition: uaccess.h:107
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
void * user_to_virt(userptr_t userptr, off_t offset)
Convert user pointer to virtual address.
void memmove_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers, allowing for overlap.
static __always_inline userptr_t trivial_virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
Definition: uaccess.h:55
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
static __always_inline unsigned long off_t offset
Definition: efi_uaccess.h:40
static __always_inline void trivial_memset_user(userptr_t buffer, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
Definition: uaccess.h:155