Home | History | Annotate | Download | only in PeiMemoryLib
      1 /** @file
      2   Declaration of internal functions for Base Memory Library.
      3 
      4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
      5   This program and the accompanying materials
      6   are licensed and made available under the terms and conditions of the BSD License
      7   which accompanies this distribution.  The full text of the license may be found at
      8   http://opensource.org/licenses/bsd-license.php.
      9 
     10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 **/
     14 
     15 #ifndef __MEM_LIB_INTERNALS__
     16 #define __MEM_LIB_INTERNALS__
     17 
     18 #include <PiPei.h>
     19 
     20 #include <Library/BaseMemoryLib.h>
     21 #include <Library/PeiServicesTablePointerLib.h>
     22 #include <Library/DebugLib.h>
     23 #include <Library/BaseLib.h>
     24 
     25 /**
     26   Copies a source buffer to a destination buffer, and returns the destination buffer.
     27 
     28   This function wraps the (*PeiServices)->CopyMem ().
     29 
     30   @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.
     31   @param  SourceBuffer        The pointer to the source buffer of the memory copy.
     32   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
     33 
     34   @return DestinationBuffer.
     35 
     36 **/
     37 VOID *
     38 EFIAPI
     39 InternalMemCopyMem (
     40   OUT     VOID                      *Destination,
     41   IN      CONST VOID                *Source,
     42   IN      UINTN                     Length
     43   );
     44 
     45 /**
     46   Fills a target buffer with a byte value, and returns the target buffer.
     47 
     48   This function wraps the (*PeiServices)->SetMem ().
     49 
     50   @param  Buffer    The memory to set.
     51   @param  Size      The number of bytes to set.
     52   @param  Value     Value of the set operation.
     53 
     54   @return Buffer.
     55 
     56 **/
     57 VOID *
     58 EFIAPI
     59 InternalMemSetMem (
     60   OUT     VOID                      *Buffer,
     61   IN      UINTN                     Size,
     62   IN      UINT8                     Value
     63   );
     64 
     65 /**
     66   Fills a target buffer with a 16-bit value, and returns the target buffer.
     67 
     68   @param  Buffer  The pointer to the target buffer to fill.
     69   @param  Length  The count of 16-bit value to fill.
     70   @param  Value   The value with which to fill Length bytes of Buffer.
     71 
     72   @return Buffer
     73 
     74 **/
     75 VOID *
     76 EFIAPI
     77 InternalMemSetMem16 (
     78   OUT     VOID                      *Buffer,
     79   IN      UINTN                     Length,
     80   IN      UINT16                    Value
     81   );
     82 
     83 /**
     84   Fills a target buffer with a 32-bit value, and returns the target buffer.
     85 
     86   @param  Buffer  The pointer to the target buffer to fill.
     87   @param  Length  The count of 32-bit value to fill.
     88   @param  Value   The value with which to fill Length bytes of Buffer.
     89 
     90   @return Buffer
     91 
     92 **/
     93 VOID *
     94 EFIAPI
     95 InternalMemSetMem32 (
     96   OUT     VOID                      *Buffer,
     97   IN      UINTN                     Length,
     98   IN      UINT32                    Value
     99   );
    100 
    101 /**
    102   Fills a target buffer with a 64-bit value, and returns the target buffer.
    103 
    104   @param  Buffer  The pointer to the target buffer to fill.
    105   @param  Length  The count of 64-bit value to fill.
    106   @param  Value   The value with which to fill Length bytes of Buffer.
    107 
    108   @return Buffer
    109 
    110 **/
    111 VOID *
    112 EFIAPI
    113 InternalMemSetMem64 (
    114   OUT     VOID                      *Buffer,
    115   IN      UINTN                     Length,
    116   IN      UINT64                    Value
    117   );
    118 
    119 /**
    120   Set Buffer to 0 for Size bytes.
    121 
    122   @param  Buffer The memory to set.
    123   @param  Length The number of bytes to set
    124 
    125   @return Buffer
    126 
    127 **/
    128 VOID *
    129 EFIAPI
    130 InternalMemZeroMem (
    131   OUT     VOID                      *Buffer,
    132   IN      UINTN                     Length
    133   );
    134 
    135 /**
    136   Compares two memory buffers of a given length.
    137 
    138   @param  DestinationBuffer The first memory buffer
    139   @param  SourceBuffer      The second memory buffer
    140   @param  Length            The length of DestinationBuffer and SourceBuffer memory
    141                             regions to compare. Must be non-zero.
    142 
    143   @return 0                 All Length bytes of the two buffers are identical.
    144   @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first
    145                             mismatched byte in DestinationBuffer.
    146 
    147 **/
    148 INTN
    149 EFIAPI
    150 InternalMemCompareMem (
    151   IN      CONST VOID                *DestinationBuffer,
    152   IN      CONST VOID                *SourceBuffer,
    153   IN      UINTN                     Length
    154   );
    155 
    156 /**
    157   Scans a target buffer for an 8-bit value, and returns a pointer to the
    158   matching 8-bit value in the target buffer.
    159 
    160   @param  Buffer  The pointer to the target buffer to scan.
    161   @param  Length  The count of 8-bit value to scan. Must be non-zero.
    162   @param  Value   The value to search for in the target buffer.
    163 
    164   @return The pointer to the first occurrence, or NULL if not found.
    165 
    166 **/
    167 CONST VOID *
    168 EFIAPI
    169 InternalMemScanMem8 (
    170   IN      CONST VOID                *Buffer,
    171   IN      UINTN                     Length,
    172   IN      UINT8                     Value
    173   );
    174 
    175 /**
    176   Scans a target buffer for a 16-bit value, and returns a pointer to the
    177   matching 16-bit value in the target buffer.
    178 
    179   @param  Buffer  The pointer to the target buffer to scan.
    180   @param  Length  The count of 16-bit value to scan. Must be non-zero.
    181   @param  Value   The value to search for in the target buffer.
    182 
    183   @return The pointer to the first occurrence, or NULL if not found.
    184 
    185 **/
    186 CONST VOID *
    187 EFIAPI
    188 InternalMemScanMem16 (
    189   IN      CONST VOID                *Buffer,
    190   IN      UINTN                     Length,
    191   IN      UINT16                    Value
    192   );
    193 
    194 /**
    195   Scans a target buffer for a 32-bit value, and returns a pointer to the
    196   matching 32-bit value in the target buffer.
    197 
    198   @param  Buffer  The pointer to the target buffer to scan.
    199   @param  Length  The count of 32-bit value to scan. Must be non-zero.
    200   @param  Value   The value to search for in the target buffer.
    201 
    202   @return The pointer to the first occurrence, or NULL if not found.
    203 
    204 **/
    205 CONST VOID *
    206 EFIAPI
    207 InternalMemScanMem32 (
    208   IN      CONST VOID                *Buffer,
    209   IN      UINTN                     Length,
    210   IN      UINT32                    Value
    211   );
    212 
    213 /**
    214   Scans a target buffer for a 64-bit value, and returns a pointer to the
    215   matching 64-bit value in the target buffer.
    216 
    217   @param  Buffer  The pointer to the target buffer to scan.
    218   @param  Length  The count of 64-bit value to scan. Must be non-zero.
    219   @param  Value   The value to search for in the target buffer.
    220 
    221   @return The pointer to the first occurrence, or NULL if not found.
    222 
    223 **/
    224 CONST VOID *
    225 EFIAPI
    226 InternalMemScanMem64 (
    227   IN      CONST VOID                *Buffer,
    228   IN      UINTN                     Length,
    229   IN      UINT64                    Value
    230   );
    231 
    232 #endif
    233