]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiMemoryLib/SetMemWrapper.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / PeiMemoryLib / SetMemWrapper.c
CommitLineData
dd51a993 1/** @file\r
f7753a96 2 SetMem() and SetMemN() implementation.\r
dd51a993 3\r
2bfb6009 4 The following BaseMemoryLib instances contain the same copy of this file:\r
dd51a993 5\r
6 BaseMemoryLib\r
7 BaseMemoryLibMmx\r
8 BaseMemoryLibSse2\r
9 BaseMemoryLibRepStr\r
2bfb6009
LG
10 BaseMemoryLibOptDxe\r
11 BaseMemoryLibOptPei\r
dd51a993 12 PeiMemoryLib\r
1fef058f 13 UefiMemoryLib\r
dd51a993 14\r
9095d37b 15 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 16 SPDX-License-Identifier: BSD-2-Clause-Patent\r
eb1c78db 17\r
dd51a993 18**/\r
19\r
20#include "MemLibInternals.h"\r
21\r
22/**\r
23 Fills a target buffer with a byte value, and returns the target buffer.\r
24\r
25 This function fills Length bytes of Buffer with Value, and returns Buffer.\r
9095d37b 26\r
cc4e0485 27 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
dd51a993 28\r
58380e9c 29 @param Buffer The memory to set.\r
2fc59a00 30 @param Length The number of bytes to set.\r
31 @param Value The value with which to fill Length bytes of Buffer.\r
dd51a993 32\r
33 @return Buffer.\r
34\r
35**/\r
36VOID *\r
37EFIAPI\r
38SetMem (\r
39 OUT VOID *Buffer,\r
40 IN UINTN Length,\r
41 IN UINT8 Value\r
42 )\r
43{\r
44 if (Length == 0) {\r
45 return Buffer;\r
46 }\r
47\r
48 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));\r
49\r
50 return InternalMemSetMem (Buffer, Length, Value);\r
51}\r
f7753a96 52\r
53/**\r
54 Fills a target buffer with a value that is size UINTN, and returns the target buffer.\r
55\r
56 This function fills Length bytes of Buffer with the UINTN sized value specified by\r
57 Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length\r
58 bytes of Buffer.\r
59\r
60 If Length > 0 and Buffer is NULL, then ASSERT().\r
61 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
62 If Buffer is not aligned on a UINTN boundary, then ASSERT().\r
63 If Length is not aligned on a UINTN boundary, then ASSERT().\r
64\r
2fc59a00 65 @param Buffer The pointer to the target buffer to fill.\r
66 @param Length The number of bytes in Buffer to fill.\r
67 @param Value The value with which to fill Length bytes of Buffer.\r
f7753a96 68\r
69 @return Buffer.\r
70\r
71**/\r
72VOID *\r
73EFIAPI\r
74SetMemN (\r
75 OUT VOID *Buffer,\r
76 IN UINTN Length,\r
77 IN UINTN Value\r
78 )\r
79{\r
80 if (sizeof (UINTN) == sizeof (UINT64)) {\r
81 return SetMem64 (Buffer, Length, (UINT64)Value);\r
56385d49 82 } else {\r
83 return SetMem32 (Buffer, Length, (UINT32)Value);\r
f7753a96 84 }\r
f7753a96 85}\r