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