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