]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiMemoryLib/SetMemWrapper.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / UefiMemoryLib / SetMemWrapper.c
... / ...
CommitLineData
1/** @file\r
2 SetMem() and SetMemN() implementation.\r
3\r
4 The following BaseMemoryLib instances contain the same copy of this file:\r
5\r
6 BaseMemoryLib\r
7 BaseMemoryLibMmx\r
8 BaseMemoryLibSse2\r
9 BaseMemoryLibRepStr\r
10 BaseMemoryLibOptDxe\r
11 BaseMemoryLibOptPei\r
12 PeiMemoryLib\r
13 UefiMemoryLib\r
14\r
15 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
16 SPDX-License-Identifier: BSD-2-Clause-Patent\r
17\r
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
26\r
27 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
28\r
29 @param Buffer Memory to set.\r
30 @param Length The number of bytes to set.\r
31 @param Value The value with which to fill Length bytes of Buffer.\r
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
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
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
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
82 } else {\r
83 return SetMem32 (Buffer, Length, (UINT32)Value);\r
84 }\r
85}\r