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