iPXE
Macros | Functions
x86_string.c File Reference

Optimised string operations. More...

#include <string.h>
#include <config/defaults.h>

Go to the source code of this file.

Macros

#define USE_GENERIC_MEMCPY_REVERSE   0
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void * __attribute__ ((noinline))
 Copy memory area. More...
 
void * __memmove (void *dest, const void *src, size_t len)
 Copy (possibly overlapping) memory area. More...
 

Detailed Description

Optimised string operations.

Definition in file x86_string.c.

Macro Definition Documentation

◆ USE_GENERIC_MEMCPY_REVERSE

#define USE_GENERIC_MEMCPY_REVERSE   0

Definition at line 39 of file x86_string.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __attribute__()

void* __attribute__ ( (noinline)  )

Copy memory area.

Copy memory area backwards.

Parameters
destDestination address
srcSource address
lenLength
Return values
destDestination address

Definition at line 50 of file x86_string.c.

51  {
52  void *edi = dest;
53  const void *esi = src;
54  int discard_ecx;
55 
56  /* We often do large dword-aligned and dword-length block
57  * moves. Using movsl rather than movsb speeds these up by
58  * around 32%.
59  */
60  __asm__ __volatile__ ( "rep movsl"
61  : "=&D" ( edi ), "=&S" ( esi ),
62  "=&c" ( discard_ecx )
63  : "0" ( edi ), "1" ( esi ), "2" ( len >> 2 )
64  : "memory" );
65  __asm__ __volatile__ ( "rep movsb"
66  : "=&D" ( edi ), "=&S" ( esi ),
67  "=&c" ( discard_ecx )
68  : "0" ( edi ), "1" ( esi ), "2" ( len & 3 )
69  : "memory" );
70  return dest;
71 }
static void const void * src
Definition: crypto.h:244
const void * esi
Definition: string.h:58
static void * dest
Definition: strings.h:176
uint32_t discard_ecx
Definition: hyperv.h:31
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
void * edi
Definition: string.h:59
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
uint32_t len
Length.
Definition: ena.h:14

References __asm__(), __volatile__(), dest, discard_ecx, edi, esi, len, and src.

◆ __memmove()

void* __memmove ( void *  dest,
const void *  src,
size_t  len 
)

Copy (possibly overlapping) memory area.

Parameters
destDestination address
srcSource address
lenLength
Return values
destDestination address

Definition at line 117 of file x86_string.c.

117  {
118 
119  if ( dest <= src ) {
120  return __memcpy ( dest, src, len );
121  } else {
122  return __memcpy_reverse ( dest, src, len );
123  }
124 }
static void const void * src
Definition: crypto.h:244
void * __memcpy_reverse(void *dest, const void *src, size_t len)
static void * dest
Definition: strings.h:176
uint32_t len
Length.
Definition: ena.h:14
void * __memcpy(void *dest, const void *src, size_t len)

References __memcpy(), __memcpy_reverse(), dest, len, and src.