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