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 } while (--Length != 0);
168
169 return NULL;
170}
171
183CONST VOID *
184EFIAPI
186 IN CONST VOID *Buffer,
187 IN UINTN Length,
188 IN UINT16 Value
189 )
190{
191 CONST UINT16 *Pointer;
192
193 Pointer = (CONST UINT16 *)Buffer;
194 do {
195 if (*(Pointer++) == Value) {
196 return --Pointer;
197 }
198 } while (--Length != 0);
199
200 return NULL;
201}
202
214CONST VOID *
215EFIAPI
217 IN CONST VOID *Buffer,
218 IN UINTN Length,
219 IN UINT32 Value
220 )
221{
222 CONST UINT32 *Pointer;
223
224 Pointer = (CONST UINT32 *)Buffer;
225 do {
226 if (*(Pointer++) == Value) {
227 return --Pointer;
228 }
229 } while (--Length != 0);
230
231 return NULL;
232}
233
245CONST VOID *
246EFIAPI
248 IN CONST VOID *Buffer,
249 IN UINTN Length,
250 IN UINT64 Value
251 )
252{
253 CONST UINT64 *Pointer;
254
255 Pointer = (CONST UINT64 *)Buffer;
256 do {
257 if (*(Pointer++) == Value) {
258 return --Pointer;
259 }
260 } while (--Length != 0);
261
262 return NULL;
263}
264
275BOOLEAN
276EFIAPI
278 IN CONST VOID *Buffer,
279 IN UINTN Length
280 )
281{
282 CONST UINT8 *BufferData;
283 UINTN Index;
284
285 BufferData = Buffer;
286 for (Index = 0; Index < Length; Index++) {
287 if (BufferData[Index] != 0) {
288 return FALSE;
289 }
290 }
291
292 return TRUE;
293}
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