2
Architecture Independent Base Memory Library Implementation.
4
The following BaseMemoryLib instances contain the same copy of this file:
9
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
10
This program and the accompanying materials
11
are licensed and made available under the terms and conditions of the BSD License
12
which accompanies this distribution. The full text of the license may be found at
13
http://opensource.org/licenses/bsd-license.php.
15
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20
#include "MemLibInternals.h"
23
Fills a target buffer with a 16-bit value, and returns the target buffer.
25
@param Buffer The pointer to the target buffer to fill.
26
@param Length The count of 16-bit value to fill.
27
@param Value The value with which to fill Length bytes of Buffer.
41
((UINT16*)Buffer)[--Length] = Value;
42
} while (Length != 0);
47
Fills a target buffer with a 32-bit value, and returns the target buffer.
49
@param Buffer The pointer to the target buffer to fill.
50
@param Length The count of 32-bit value to fill.
51
@param Value The value with which to fill Length bytes of Buffer.
65
((UINT32*)Buffer)[--Length] = Value;
66
} while (Length != 0);
71
Fills a target buffer with a 64-bit value, and returns the target buffer.
73
@param Buffer The pointer to the target buffer to fill.
74
@param Length The count of 64-bit value to fill.
75
@param Value The value with which to fill Length bytes of Buffer.
89
((UINT64*)Buffer)[--Length] = Value;
90
} while (Length != 0);
95
Set Buffer to 0 for Size bytes.
97
@param Buffer Memory to set.
98
@param Length The number of bytes to set
110
return InternalMemSetMem (Buffer, Length, 0);
114
Compares two memory buffers of a given length.
116
@param DestinationBuffer The first memory buffer
117
@param SourceBuffer The second memory buffer
118
@param Length The length of DestinationBuffer and SourceBuffer memory
119
regions to compare. Must be non-zero.
121
@return 0 All Length bytes of the two buffers are identical.
122
@retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
123
mismatched byte in DestinationBuffer.
128
InternalMemCompareMem (
129
IN CONST VOID *DestinationBuffer,
130
IN CONST VOID *SourceBuffer,
134
while ((--Length != 0) &&
135
(*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {
136
DestinationBuffer = (INT8*)DestinationBuffer + 1;
137
SourceBuffer = (INT8*)SourceBuffer + 1;
139
return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;
143
Scans a target buffer for an 8-bit value, and returns a pointer to the
144
matching 8-bit value in the target buffer.
146
@param Buffer The pointer to the target buffer to scan.
147
@param Length The count of 8-bit value to scan. Must be non-zero.
148
@param Value The value to search for in the target buffer.
150
@return The pointer to the first occurrence or NULL if not found.
155
InternalMemScanMem8 (
156
IN CONST VOID *Buffer,
161
CONST UINT8 *Pointer;
163
Pointer = (CONST UINT8*)Buffer;
165
if (*(Pointer++) == Value) {
168
} while (--Length != 0);
173
Scans a target buffer for a 16-bit value, and returns a pointer to the
174
matching 16-bit value in the target buffer.
176
@param Buffer The pointer to the target buffer to scan.
177
@param Length The count of 16-bit value to scan. Must be non-zero.
178
@param Value The value to search for in the target buffer.
180
@return The pointer to the first occurrence or NULL if not found.
185
InternalMemScanMem16 (
186
IN CONST VOID *Buffer,
191
CONST UINT16 *Pointer;
193
Pointer = (CONST UINT16*)Buffer;
195
if (*(Pointer++) == Value) {
198
} while (--Length != 0);
203
Scans a target buffer for a 32-bit value, and returns a pointer to the
204
matching 32-bit value in the target buffer.
206
@param Buffer The pointer to the target buffer to scan.
207
@param Length The count of 32-bit value to scan. Must be non-zero.
208
@param Value The value to search for in the target buffer.
210
@return The pointer to the first occurrence or NULL if not found.
215
InternalMemScanMem32 (
216
IN CONST VOID *Buffer,
221
CONST UINT32 *Pointer;
223
Pointer = (CONST UINT32*)Buffer;
225
if (*(Pointer++) == Value) {
228
} while (--Length != 0);
233
Scans a target buffer for a 64-bit value, and returns a pointer to the
234
matching 64-bit value in the target buffer.
236
@param Buffer The pointer to the target buffer to scan.
237
@param Length The count of 64-bit value to scan. Must be non-zero.
238
@param Value The value to search for in the target buffer.
240
@return The pointer to the first occurrence or NULL if not found.
245
InternalMemScanMem64 (
246
IN CONST VOID *Buffer,
251
CONST UINT64 *Pointer;
253
Pointer = (CONST UINT64*)Buffer;
255
if (*(Pointer++) == Value) {
258
} while (--Length != 0);