1 | /** @file
|
---|
2 | ScanMem64() implementation.
|
---|
3 |
|
---|
4 | The following BaseMemoryLib instances contain the same copy of this file:
|
---|
5 |
|
---|
6 | BaseMemoryLib
|
---|
7 | BaseMemoryLibMmx
|
---|
8 | BaseMemoryLibSse2
|
---|
9 | BaseMemoryLibRepStr
|
---|
10 | BaseMemoryLibOptDxe
|
---|
11 | BaseMemoryLibOptPei
|
---|
12 | PeiMemoryLib
|
---|
13 | UefiMemoryLib
|
---|
14 |
|
---|
15 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
16 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
17 |
|
---|
18 | **/
|
---|
19 |
|
---|
20 | #include "MemLibInternals.h"
|
---|
21 |
|
---|
22 | /**
|
---|
23 | Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
|
---|
24 | in the target buffer.
|
---|
25 |
|
---|
26 | This function searches the target buffer specified by Buffer and Length from the lowest
|
---|
27 | address to the highest address for a 64-bit value that matches Value. If a match is found,
|
---|
28 | then a pointer to the matching byte in the target buffer is returned. If no match is found,
|
---|
29 | then NULL is returned. If Length is 0, then NULL is returned.
|
---|
30 |
|
---|
31 | If Length > 0 and Buffer is NULL, then ASSERT().
|
---|
32 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
---|
33 | If Length is not aligned on a 64-bit boundary, then ASSERT().
|
---|
34 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
35 |
|
---|
36 | @param Buffer The pointer to the target buffer to scan.
|
---|
37 | @param Length The number of bytes in Buffer to scan.
|
---|
38 | @param Value The value to search for in the target buffer.
|
---|
39 |
|
---|
40 | @return A pointer to the matching byte in the target buffer or NULL otherwise.
|
---|
41 |
|
---|
42 | **/
|
---|
43 | VOID *
|
---|
44 | EFIAPI
|
---|
45 | ScanMem64 (
|
---|
46 | IN CONST VOID *Buffer,
|
---|
47 | IN UINTN Length,
|
---|
48 | IN UINT64 Value
|
---|
49 | )
|
---|
50 | {
|
---|
51 | if (Length == 0) {
|
---|
52 | return NULL;
|
---|
53 | }
|
---|
54 |
|
---|
55 | ASSERT (Buffer != NULL);
|
---|
56 | ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);
|
---|
57 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
|
---|
58 | ASSERT ((Length & (sizeof (Value) - 1)) == 0);
|
---|
59 |
|
---|
60 | return (VOID *)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);
|
---|
61 | }
|
---|