TianoCore EDK2 master
Loading...
Searching...
No Matches
MemLibGeneric.c
Go to the documentation of this file.
1
14#include "MemLibInternals.h"
15
26VOID *
27EFIAPI
29 OUT VOID *Buffer,
30 IN UINTN Length,
31 IN UINT16 Value
32 )
33{
34 for ( ; Length != 0; Length--) {
35 ((UINT16 *)Buffer)[Length - 1] = Value;
36 }
37
38 return Buffer;
39}
40
51VOID *
52EFIAPI
54 OUT VOID *Buffer,
55 IN UINTN Length,
56 IN UINT32 Value
57 )
58{
59 for ( ; Length != 0; Length--) {
60 ((UINT32 *)Buffer)[Length - 1] = Value;
61 }
62
63 return Buffer;
64}
65
76VOID *
77EFIAPI
79 OUT VOID *Buffer,
80 IN UINTN Length,
81 IN UINT64 Value
82 )
83{
84 for ( ; Length != 0; Length--) {
85 ((UINT64 *)Buffer)[Length - 1] = Value;
86 }
87
88 return Buffer;
89}
90
100VOID *
101EFIAPI
103 OUT VOID *Buffer,
104 IN UINTN Length
105 )
106{
107 return InternalMemSetMem (Buffer, Length, 0);
108}
109
123INTN
124EFIAPI
126 IN CONST VOID *DestinationBuffer,
127 IN CONST VOID *SourceBuffer,
128 IN UINTN Length
129 )
130{
131 while ((--Length != 0) &&
132 (*(INT8 *)DestinationBuffer == *(INT8 *)SourceBuffer))
133 {
134 DestinationBuffer = (INT8 *)DestinationBuffer + 1;
135 SourceBuffer = (INT8 *)SourceBuffer + 1;
136 }
137
138 return (INTN)*(UINT8 *)DestinationBuffer - (INTN)*(UINT8 *)SourceBuffer;
139}
140
152CONST VOID *
153EFIAPI
155 IN CONST VOID *Buffer,
156 IN UINTN Length,
157 IN UINT8 Value
158 )
159{
160 CONST UINT8 *Pointer;
161
162 Pointer = (CONST UINT8 *)Buffer;
163 do {
164 if (*Pointer == Value) {
165 return Pointer;
166 }
167
168 ++Pointer;
169 } while (--Length != 0);
170
171 return NULL;
172}
173
185CONST VOID *
186EFIAPI
188 IN CONST VOID *Buffer,
189 IN UINTN Length,
190 IN UINT16 Value
191 )
192{
193 CONST UINT16 *Pointer;
194
195 Pointer = (CONST UINT16 *)Buffer;
196 do {
197 if (*Pointer == Value) {
198 return Pointer;
199 }
200
201 ++Pointer;
202 } while (--Length != 0);
203
204 return NULL;
205}
206
218CONST VOID *
219EFIAPI
221 IN CONST VOID *Buffer,
222 IN UINTN Length,
223 IN UINT32 Value
224 )
225{
226 CONST UINT32 *Pointer;
227
228 Pointer = (CONST UINT32 *)Buffer;
229 do {
230 if (*Pointer == Value) {
231 return Pointer;
232 }
233
234 ++Pointer;
235 } while (--Length != 0);
236
237 return NULL;
238}
239
251CONST VOID *
252EFIAPI
254 IN CONST VOID *Buffer,
255 IN UINTN Length,
256 IN UINT64 Value
257 )
258{
259 CONST UINT64 *Pointer;
260
261 Pointer = (CONST UINT64 *)Buffer;
262 do {
263 if (*Pointer == Value) {
264 return Pointer;
265 }
266
267 ++Pointer;
268 } while (--Length != 0);
269
270 return NULL;
271}
272
283BOOLEAN
284EFIAPI
286 IN CONST VOID *Buffer,
287 IN UINTN Length
288 )
289{
290 CONST UINT8 *BufferData;
291 UINTN Index;
292
293 BufferData = Buffer;
294 for (Index = 0; Index < Length; Index++) {
295 if (BufferData[Index] != 0) {
296 return FALSE;
297 }
298 }
299
300 return TRUE;
301}
UINT64 UINTN
INT64 INTN
VOID *EFIAPI InternalMemSetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
Definition: MemLibGeneric.c:53
VOID *EFIAPI InternalMemSetMem64(OUT VOID *Buffer, IN UINTN Length, IN UINT64 Value)
Definition: MemLibGeneric.c:78
CONST VOID *EFIAPI InternalMemScanMem32(IN CONST VOID *Buffer, IN UINTN Length, IN UINT32 Value)
CONST VOID *EFIAPI InternalMemScanMem64(IN CONST VOID *Buffer, IN UINTN Length, IN UINT64 Value)
CONST VOID *EFIAPI InternalMemScanMem8(IN CONST VOID *Buffer, IN UINTN Length, IN UINT8 Value)
BOOLEAN EFIAPI InternalMemIsZeroBuffer(IN CONST VOID *Buffer, IN UINTN Length)
INTN EFIAPI InternalMemCompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
CONST VOID *EFIAPI InternalMemScanMem16(IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 Value)
VOID *EFIAPI InternalMemZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI InternalMemSetMem16(OUT VOID *Buffer, IN UINTN Length, IN UINT16 Value)
Definition: MemLibGeneric.c:28
VOID *EFIAPI InternalMemSetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
Definition: SetMem.c:29
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284