SetMemWrapper.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /** @file
  2. SetMem() and SetMemN() 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. Fills a target buffer with a byte value, and returns the target buffer.
  23. This function fills Length bytes of Buffer with Value, and returns Buffer.
  24. If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
  25. @param Buffer Memory to set.
  26. @param Length Number of bytes to set.
  27. @param Value Value with which to fill Length bytes of Buffer.
  28. @return Buffer.
  29. **/
  30. VOID *
  31. EFIAPI
  32. SetMem (
  33. OUT VOID *Buffer,
  34. IN UINTN Length,
  35. IN UINT8 Value
  36. )
  37. {
  38. if (Length == 0) {
  39. return Buffer;
  40. }
  41. ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
  42. return InternalMemSetMem (Buffer, Length, Value);
  43. }
  44. /**
  45. Fills a target buffer with a value that is size UINTN, and returns the target buffer.
  46. This function fills Length bytes of Buffer with the UINTN sized value specified by
  47. Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length
  48. bytes of Buffer.
  49. If Length > 0 and Buffer is NULL, then ASSERT().
  50. If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
  51. If Buffer is not aligned on a UINTN boundary, then ASSERT().
  52. If Length is not aligned on a UINTN boundary, then ASSERT().
  53. @param Buffer Pointer to the target buffer to fill.
  54. @param Length Number of bytes in Buffer to fill.
  55. @param Value Value with which to fill Length bytes of Buffer.
  56. @return Buffer.
  57. **/
  58. VOID *
  59. EFIAPI
  60. SetMemN (
  61. OUT VOID *Buffer,
  62. IN UINTN Length,
  63. IN UINTN Value
  64. )
  65. {
  66. if (sizeof (UINTN) == sizeof (UINT64)) {
  67. return SetMem64 (Buffer, Length, (UINT64)Value);
  68. } else {
  69. return SetMem32 (Buffer, Length, (UINT32)Value);
  70. }
  71. }