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

Detailed Description

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


Function Documentation

static __always_inline userptr_t trivial_virt_to_user ( volatile const void *  addr) [inline, static]

Convert virtual address to user pointer.

Parameters:
addrVirtual address
Return values:
userptrUser pointer

Definition at line 55 of file uaccess.h.

                                                   {
        return ( ( userptr_t ) addr );
}
static __always_inline void* trivial_user_to_virt ( userptr_t  userptr,
off_t  offset 
) [inline, static]

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.

                                                         {
        return ( ( void * ) userptr + offset );
}
static __always_inline userptr_t trivial_userptr_add ( userptr_t  userptr,
off_t  offset 
) [inline, static]

Add offset to user pointer.

Parameters:
userptrUser pointer
offsetOffset
Return values:
userptrNew pointer value

Definition at line 81 of file uaccess.h.

                                                        {
        return ( userptr + offset );
}
static __always_inline off_t trivial_userptr_sub ( userptr_t  userptr,
userptr_t  subtrahend 
) [inline, static]

Subtract user pointers.

Parameters:
userptrUser pointer
subtrahendUser pointer to be subtracted
Return values:
offsetOffset

Definition at line 93 of file uaccess.h.

                                                                {
        return ( userptr - subtrahend );
}
static __always_inline void trivial_memcpy_user ( userptr_t  dest,
off_t  dest_off,
userptr_t  src,
off_t  src_off,
size_t  len 
) [inline, static]

Copy data between user buffers.

Parameters:
destDestination
dest_offDestination offset
srcSource
src_offSource offset
lenLength

Definition at line 107 of file uaccess.h.

References memcpy().

                                                                 {
        memcpy ( ( ( void * ) dest + dest_off ),
                 ( ( void * ) src + src_off ), len );
}
static __always_inline void trivial_memmove_user ( userptr_t  dest,
off_t  dest_off,
userptr_t  src,
off_t  src_off,
size_t  len 
) [inline, static]

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.

References memmove().

                                                                  {
        memmove ( ( ( void * ) dest + dest_off ),
                  ( ( void * ) src + src_off ), len );
}
static __always_inline int trivial_memcmp_user ( userptr_t  first,
off_t  first_off,
userptr_t  second,
off_t  second_off,
size_t  len 
) [inline, static]

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.

References memcmp().

                                                                       {
        return memcmp ( ( ( void * ) first + first_off ),
                        ( ( void * ) second + second_off ), len );
}
static __always_inline void trivial_memset_user ( userptr_t  buffer,
off_t  offset,
int  c,
size_t  len 
) [inline, static]

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.

References memset().

                                                                          {
        memset ( ( ( void * ) buffer + offset ), c, len );
}
static __always_inline size_t trivial_strlen_user ( userptr_t  buffer,
off_t  offset 
) [inline, static]

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.

References strlen().

                                                       {
        return strlen ( ( void * ) buffer + offset );
}
static __always_inline off_t trivial_memchr_user ( userptr_t  buffer,
off_t  offset,
int  c,
size_t  len 
) [inline, static]

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.

References memchr().

                                                                          {
        void *found;

        found = memchr ( ( ( void * ) buffer + offset ), c, len );
        return ( found ? ( found - ( void * ) buffer ) : -1 );
}