iPXE
Functions
Trivial user access API implementations

User access API implementations that can be used by environments in which virtual addresses allow access to all of memory. More...

Functions

static __always_inline userptr_t trivial_virt_to_user (volatile const void *addr)
 Convert virtual address to user pointer. More...
 
static __always_inline void * trivial_user_to_virt (userptr_t userptr, off_t offset)
 Convert user pointer to virtual address. More...
 
static __always_inline userptr_t trivial_userptr_add (userptr_t userptr, off_t offset)
 Add offset to user pointer. More...
 
static __always_inline off_t trivial_userptr_sub (userptr_t userptr, userptr_t subtrahend)
 Subtract user pointers. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static __always_inline size_t trivial_strlen_user (userptr_t buffer, off_t offset)
 Find length of NUL-terminated string in user buffer. More...
 
static __always_inline off_t trivial_memchr_user (userptr_t buffer, off_t offset, int c, size_t len)
 Find character in user buffer. More...
 

Detailed Description

User access API implementations that can be used by environments in which virtual addresses allow access to all of memory.

Function Documentation

◆ trivial_virt_to_user()

static __always_inline userptr_t trivial_virt_to_user ( volatile const void *  addr)
inlinestatic

Convert virtual address to user pointer.

Parameters
addrVirtual address
Return values
userptrUser pointer

Definition at line 55 of file uaccess.h.

55  {
56  return ( ( userptr_t ) addr );
57 }
u32 addr
Definition: sky2.h:8
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33

References addr.

Referenced by UACCESS_INLINE().

◆ trivial_user_to_virt()

static __always_inline void* trivial_user_to_virt ( userptr_t  userptr,
off_t  offset 
)
inlinestatic

Convert user pointer to virtual address.

Parameters
userptrUser pointer
offsetOffset from user pointer
Return values
addrVirtual address

This operation is not available under all memory models.

Definition at line 69 of file uaccess.h.

69  {
70  return ( ( void * ) userptr + offset );
71 }
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259

References offset.

◆ trivial_userptr_add()

static __always_inline userptr_t trivial_userptr_add ( userptr_t  userptr,
off_t  offset 
)
inlinestatic

Add offset to user pointer.

Parameters
userptrUser pointer
offsetOffset
Return values
userptrNew pointer value

Definition at line 81 of file uaccess.h.

81  {
82  return ( userptr + offset );
83 }
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259

References offset.

◆ trivial_userptr_sub()

static __always_inline off_t trivial_userptr_sub ( userptr_t  userptr,
userptr_t  subtrahend 
)
inlinestatic

Subtract user pointers.

Parameters
userptrUser pointer
subtrahendUser pointer to be subtracted
Return values
offsetOffset

Definition at line 93 of file uaccess.h.

93  {
94  return ( userptr - subtrahend );
95 }
static __always_inline off_t userptr_t subtrahend
Definition: efi_uaccess.h:61

References subtrahend.

◆ trivial_memcpy_user()

static __always_inline void trivial_memcpy_user ( userptr_t  dest,
off_t  dest_off,
userptr_t  src,
off_t  src_off,
size_t  len 
)
inlinestatic

Copy data between user buffers.

Parameters
destDestination
dest_offDestination offset
srcSource
src_offSource offset
lenLength

Definition at line 107 of file uaccess.h.

108  {
109  memcpy ( ( ( void * ) dest + dest_off ),
110  ( ( void * ) src + src_off ), len );
111 }
static __always_inline void off_t userptr_t off_t src_off
Definition: efi_uaccess.h:66
static __always_inline void off_t dest_off
Definition: efi_uaccess.h:66
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void * dest
Definition: strings.h:176
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
uint32_t len
Length.
Definition: ena.h:14

References dest, dest_off, len, memcpy(), src, and src_off.

◆ trivial_memmove_user()

static __always_inline void trivial_memmove_user ( userptr_t  dest,
off_t  dest_off,
userptr_t  src,
off_t  src_off,
size_t  len 
)
inlinestatic

Copy data between user buffers, allowing for overlap.

Parameters
destDestination
dest_offDestination offset
srcSource
src_offSource offset
lenLength

Definition at line 123 of file uaccess.h.

124  {
125  memmove ( ( ( void * ) dest + dest_off ),
126  ( ( void * ) src + src_off ), len );
127 }
static __always_inline void off_t userptr_t off_t src_off
Definition: efi_uaccess.h:66
static __always_inline void off_t dest_off
Definition: efi_uaccess.h:66
static void * dest
Definition: strings.h:176
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
void * memmove(void *dest, const void *src, size_t len) __nonnull
uint32_t len
Length.
Definition: ena.h:14

References dest, dest_off, len, memmove(), src, and src_off.

◆ trivial_memcmp_user()

static __always_inline int trivial_memcmp_user ( userptr_t  first,
off_t  first_off,
userptr_t  second,
off_t  second_off,
size_t  len 
)
inlinestatic

Compare data between user buffers.

Parameters
firstFirst buffer
first_offFirst buffer offset
secondSecond buffer
second_offSecond buffer offset
lenLength
Return values
diffDifference

Definition at line 140 of file uaccess.h.

141  {
142  return memcmp ( ( ( void * ) first + first_off ),
143  ( ( void * ) second + second_off ), len );
144 }
static __always_inline int off_t userptr_t second
Definition: efi_uaccess.h:80
static __always_inline int off_t userptr_t off_t second_off
Definition: efi_uaccess.h:80
static __always_inline int off_t first_off
Definition: efi_uaccess.h:80
uint32_t len
Length.
Definition: ena.h:14
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23

References first, first_off, len, memcmp(), second, and second_off.

◆ trivial_memset_user()

static __always_inline void trivial_memset_user ( userptr_t  buffer,
off_t  offset,
int  c,
size_t  len 
)
inlinestatic

Fill user buffer with a constant byte.

Parameters
bufferUser buffer
offsetOffset within buffer
cConstant byte with which to fill
lenLength

Definition at line 155 of file uaccess.h.

155  {
156  memset ( ( ( void * ) buffer + offset ), c, len );
157 }
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 userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
uint32_t len
Length.
Definition: ena.h:14
void * memset(void *dest, int character, size_t len) __nonnull

References buffer, c, len, memset(), and offset.

◆ trivial_strlen_user()

static __always_inline size_t trivial_strlen_user ( userptr_t  buffer,
off_t  offset 
)
inlinestatic

Find length of NUL-terminated string in user buffer.

Parameters
bufferUser buffer
offsetOffset within buffer
Return values
lenLength of string (excluding NUL)

Definition at line 167 of file uaccess.h.

167  {
168  return strlen ( ( void * ) buffer + offset );
169 }
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
size_t strlen(const char *src)
Get length of string.
Definition: string.c:213

References buffer, offset, and strlen().

◆ trivial_memchr_user()

static __always_inline off_t trivial_memchr_user ( userptr_t  buffer,
off_t  offset,
int  c,
size_t  len 
)
inlinestatic

Find character in user buffer.

Parameters
bufferUser buffer
offsetStarting offset within buffer
cCharacter to search for
lenLength of user buffer
Return values
offsetOffset of character, or <0 if not found

Definition at line 181 of file uaccess.h.

181  {
182  void *found;
183 
184  found = memchr ( ( ( void * ) buffer + offset ), c, len );
185  return ( found ? ( found - ( void * ) buffer ) : -1 );
186 }
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
void * memchr(const void *src, int character, size_t len)
Find character within a memory region.
Definition: string.c:119
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
uint32_t len
Length.
Definition: ena.h:14

References buffer, c, len, memchr(), and offset.