]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/BaseMemoryLibStm/AArch64/SetMem.c
3 Copyright (c) 2012-2013, ARM Ltd. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "MemLibInternals.h"
18 Set Buffer to Value for Size bytes.
20 @param Buffer Memory to set.
21 @param Length Number of bytes to set
22 @param Value Value of the set operation.
36 // Declare the local variables that actually move the data elements as
37 // volatile to prevent the optimizer from replacing this function with
38 // the intrinsic memset()
40 volatile UINT8
*Pointer8
;
41 volatile UINT32
*Pointer32
;
42 volatile UINT64
*Pointer64
;
46 if ((((UINTN
)Buffer
& 0x7) == 0) && (Length
>= 8)) {
47 // Generate the 64bit value
48 Value32
= (Value
<< 24) | (Value
<< 16) | (Value
<< 8) | Value
;
49 Value64
= (((UINT64
)Value32
) << 32) | Value32
;
51 Pointer64
= (UINT64
*)Buffer
;
53 *(Pointer64
++) = Value64
;
57 // Finish with bytes if needed
58 Pointer8
= (UINT8
*)Pointer64
;
59 while (Length
-- > 0) {
60 *(Pointer8
++) = Value
;
62 } else if ((((UINTN
)Buffer
& 0x3) == 0) && (Length
>= 4)) {
63 // Generate the 32bit value
64 Value32
= (Value
<< 24) | (Value
<< 16) | (Value
<< 8) | Value
;
66 Pointer32
= (UINT32
*)Buffer
;
68 *(Pointer32
++) = Value32
;
72 // Finish with bytes if needed
73 Pointer8
= (UINT8
*)Pointer32
;
74 while (Length
-- > 0) {
75 *(Pointer8
++) = Value
;
78 Pointer8
= (UINT8
*)Buffer
;
79 while (Length
-- > 0) {
80 *(Pointer8
++) = Value
;