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 61 of file uaccess.h.

61  {
62  return ( ( userptr_t ) addr );
63 }
uint32_t userptr_t
A pointer to a user buffer.
Definition: libkir.h:159
u32 addr
Definition: sky2.h:8

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 75 of file uaccess.h.

75  {
76  return ( ( void * ) userptr + offset );
77 }
static __always_inline unsigned long off_t offset
Definition: uaccess.h:231

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 87 of file uaccess.h.

87  {
88  return ( userptr + offset );
89 }
static __always_inline unsigned long off_t offset
Definition: uaccess.h:231

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 99 of file uaccess.h.

99  {
100  return ( userptr - subtrahend );
101 }
static __always_inline off_t userptr_t subtrahend
Definition: uaccess.h:252

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 113 of file uaccess.h.

114  {
115  memcpy ( ( ( void * ) dest + dest_off ),
116  ( ( void * ) src + src_off ), len );
117 }
static __always_inline void off_t userptr_t off_t size_t len
Definition: uaccess.h:259
static __always_inline void off_t userptr_t src
Definition: uaccess.h:257
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void off_t dest_off
Definition: uaccess.h:257
static __always_inline void off_t userptr_t off_t src_off
Definition: uaccess.h:257
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150

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 129 of file uaccess.h.

130  {
131  memmove ( ( ( void * ) dest + dest_off ),
132  ( ( void * ) src + src_off ), len );
133 }
static __always_inline void off_t userptr_t off_t size_t len
Definition: uaccess.h:259
static __always_inline void off_t userptr_t src
Definition: uaccess.h:257
static __always_inline void off_t dest_off
Definition: uaccess.h:257
static __always_inline void off_t userptr_t off_t src_off
Definition: uaccess.h:257
void * memmove(void *dest, const void *src, size_t len) __nonnull
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150

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 146 of file uaccess.h.

147  {
148  return memcmp ( ( ( void * ) first + first_off ),
149  ( ( void * ) second + second_off ), len );
150 }
static __always_inline void off_t userptr_t off_t size_t len
Definition: uaccess.h:259
uint32_t first
First block in range.
Definition: pccrr.h:14
static __always_inline int off_t first_off
Definition: uaccess.h:271
static __always_inline int off_t userptr_t second
Definition: uaccess.h:271
static __always_inline int off_t userptr_t off_t second_off
Definition: uaccess.h:271
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114

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 161 of file uaccess.h.

161  {
162  memset ( ( ( void * ) buffer + offset ), c, len );
163 }
static __always_inline void off_t userptr_t off_t size_t len
Definition: uaccess.h:259
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
static __always_inline unsigned long off_t offset
Definition: uaccess.h:231
static __always_inline void off_t int c
Definition: uaccess.h:278
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 173 of file uaccess.h.

173  {
174  return strlen ( ( void * ) buffer + offset );
175 }
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
static __always_inline unsigned long off_t offset
Definition: uaccess.h:231

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 187 of file uaccess.h.

187  {
188  void *found;
189 
190  found = memchr ( ( ( void * ) buffer + offset ), c, len );
191  return ( found ? ( found - ( void * ) buffer ) : -1 );
192 }
static __always_inline void off_t userptr_t off_t size_t len
Definition: uaccess.h:259
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
void * memchr(const void *src, int character, size_t len)
Find character within a memory region.
Definition: string.c:135
static __always_inline unsigned long off_t offset
Definition: uaccess.h:231
static __always_inline void off_t int c
Definition: uaccess.h:278

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