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