]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibOptDxe/Arm/ScanMemGeneric.c
2 Architecture Independent Base Memory Library Implementation.
4 The following BaseMemoryLib instances contain the same copy of this file:
9 Copyright (c) 2006 - 2016, 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 Scans a target buffer for a 16-bit value, and returns a pointer to the
24 matching 16-bit value in the target buffer.
26 @param Buffer The pointer to the target buffer to scan.
27 @param Length The count of 16-bit value to scan. Must be non-zero.
28 @param Value The value to search for in the target buffer.
30 @return The pointer to the first occurrence, or NULL if not found.
35 InternalMemScanMem16 (
36 IN CONST VOID
*Buffer
,
41 CONST UINT16
*Pointer
;
43 Pointer
= (CONST UINT16
*)Buffer
;
45 if (*Pointer
== Value
) {
49 } while (--Length
!= 0);
54 Scans a target buffer for a 32-bit value, and returns a pointer to the
55 matching 32-bit value in the target buffer.
57 @param Buffer The pointer to the target buffer to scan.
58 @param Length The count of 32-bit value to scan. Must be non-zero.
59 @param Value The value to search for in the target buffer.
61 @return The pointer to the first occurrence, or NULL if not found.
66 InternalMemScanMem32 (
67 IN CONST VOID
*Buffer
,
72 CONST UINT32
*Pointer
;
74 Pointer
= (CONST UINT32
*)Buffer
;
76 if (*Pointer
== Value
) {
80 } while (--Length
!= 0);
85 Scans a target buffer for a 64-bit value, and returns a pointer to the
86 matching 64-bit value in the target buffer.
88 @param Buffer The pointer to the target buffer to scan.
89 @param Length The count of 64-bit value to scan. Must be non-zero.
90 @param Value The value to search for in the target buffer.
92 @return The pointer to the first occurrence, or NULL if not found.
97 InternalMemScanMem64 (
98 IN CONST VOID
*Buffer
,
103 CONST UINT64
*Pointer
;
105 Pointer
= (CONST UINT64
*)Buffer
;
107 if (*Pointer
== Value
) {
111 } while (--Length
!= 0);
116 Checks whether the contents of a buffer are all zeros.
118 @param Buffer The pointer to the buffer to be checked.
119 @param Length The size of the buffer (in bytes) to be checked.
121 @retval TRUE Contents of the buffer are all zeros.
122 @retval FALSE Contents of the buffer are not all zeros.
127 InternalMemIsZeroBuffer (
128 IN CONST VOID
*Buffer
,
132 CONST UINT8
*BufferData
;
136 for (Index
= 0; Index
< Length
; Index
++) {
137 if (BufferData
[Index
] != 0) {