1 /** @file
2 SetMem16() implementation.
3
4 The following BaseMemoryLib instances contain the same copy of this file:
5 BaseMemoryLib
6 BaseMemoryLibMmx
7 BaseMemoryLibSse2
8 BaseMemoryLibRepStr
9 BaseMemoryLibOptDxe
10 BaseMemoryLibOptPei
11 PeiMemoryLib
12 UefiMemoryLib
13
14 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
15 This program and the accompanying materials
16 are licensed and made available under the terms and conditions of the BSD License
17 which accompanies this distribution. The full text of the license may be found at
18 http://opensource.org/licenses/bsd-license.php.
19
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22
23 **/
24
25 #include "MemLibInternals.h"
26
27 /**
28 Fills a target buffer with a 16-bit value, and returns the target buffer.
29
30 This function fills Length bytes of Buffer with the 16-bit value specified by
31 Value, and returns Buffer. Value is repeated every 16-bits in for Length
32 bytes of Buffer.
33
34 If Length > 0 and Buffer is NULL, then ASSERT().
35 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
36 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
37 If Length is not aligned on a 16-bit boundary, then ASSERT().
38
39 @param Buffer The pointer to the target buffer to fill.
40 @param Length The number of bytes in Buffer to fill.
41 @param Value The value with which to fill Length bytes of Buffer.
42
43 @return Buffer.
44
45 **/
46 VOID *
47 EFIAPI
SetMem16(OUT VOID * Buffer,IN UINTN Length,IN UINT16 Value)48 SetMem16 (
49 OUT VOID *Buffer,
50 IN UINTN Length,
51 IN UINT16 Value
52 )
53 {
54 if (Length == 0) {
55 return Buffer;
56 }
57
58 ASSERT (Buffer != NULL);
59 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
60 ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);
61 ASSERT ((Length & (sizeof (Value) - 1)) == 0);
62
63 return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value);
64 }
65