ScanMem64Wrapper.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /** @file
  2. ScanMem64() implementation.
  3. The following BaseMemoryLib instances contain the same copy of this file:
  4. BaseMemoryLib
  5. BaseMemoryLibMmx
  6. BaseMemoryLibSse2
  7. BaseMemoryLibRepStr
  8. BaseMemoryLibOptDxe
  9. BaseMemoryLibOptPei
  10. PeiMemoryLib
  11. UefiMemoryLib
  12. Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
  13. This program and the accompanying materials
  14. are licensed and made available under the terms and conditions of the BSD License
  15. which accompanies this distribution. The full text of the license may be found at
  16. http://opensource.org/licenses/bsd-license.php
  17. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  18. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  19. **/
  20. #include "MemLibInternals.h"
  21. /**
  22. Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
  23. in the target buffer.
  24. This function searches the target buffer specified by Buffer and Length from the lowest
  25. address to the highest address for a 64-bit value that matches Value. If a match is found,
  26. then a pointer to the matching byte in the target buffer is returned. If no match is found,
  27. then NULL is returned. If Length is 0, then NULL is returned.
  28. If Length > 0 and Buffer is NULL, then ASSERT().
  29. If Buffer is not aligned on a 64-bit boundary, then ASSERT().
  30. If Length is not aligned on a 64-bit boundary, then ASSERT().
  31. If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
  32. @param Buffer Pointer to the target buffer to scan.
  33. @param Length Number of bytes in Buffer to scan.
  34. @param Value Value to search for in the target buffer.
  35. @return A pointer to the matching byte in the target buffer or NULL otherwise.
  36. **/
  37. VOID *
  38. EFIAPI
  39. ScanMem64 (
  40. IN CONST VOID *Buffer,
  41. IN UINTN Length,
  42. IN UINT64 Value
  43. )
  44. {
  45. if (Length == 0) {
  46. return NULL;
  47. }
  48. ASSERT (Buffer != NULL);
  49. ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);
  50. ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
  51. ASSERT ((Length & (sizeof (Value) - 1)) == 0);
  52. return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);
  53. }