]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.asm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / Arm / SetMem.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
4 ;
5 ; SPDX-License-Identifier: BSD-2-Clause-Patent
6 ;
7 ;------------------------------------------------------------------------------
8
9 EXPORT InternalMemZeroMem
10 EXPORT InternalMemSetMem
11 EXPORT InternalMemSetMem16
12 EXPORT InternalMemSetMem32
13 EXPORT InternalMemSetMem64
14
15 AREA SetMem, CODE, READONLY, CODEALIGN, ALIGN=5
16 THUMB
17
18 InternalMemSetMem16
19 uxth r2, r2
20 lsl r1, r1, #1
21 orr r2, r2, r2, lsl #16
22 b B0
23
24 InternalMemSetMem32
25 lsl r1, r1, #2
26 b B0
27
28 InternalMemSetMem64
29 lsl r1, r1, #3
30 b B1
31
32 ALIGN 32
33 InternalMemSetMem
34 uxtb r2, r2
35 orr r2, r2, r2, lsl #8
36 orr r2, r2, r2, lsl #16
37 b B0
38
39 InternalMemZeroMem
40 movs r2, #0
41 B0
42 mov r3, r2
43
44 B1
45 push {r4, lr}
46 cmp r1, #16 ; fewer than 16 bytes of input?
47 add r1, r1, r0 ; r1 := dst + length
48 add lr, r0, #16
49 blt L2
50 bic lr, lr, #15 ; align output pointer
51
52 str r2, [r0] ; potentially unaligned store of 4 bytes
53 str r3, [r0, #4] ; potentially unaligned store of 4 bytes
54 str r2, [r0, #8] ; potentially unaligned store of 4 bytes
55 str r3, [r0, #12] ; potentially unaligned store of 4 bytes
56 beq L1
57
58 L0
59 add lr, lr, #16 ; advance the output pointer by 16 bytes
60 subs r4, r1, lr ; past the output?
61 blt L3 ; break out of the loop
62 strd r2, r3, [lr, #-16] ; aligned store of 16 bytes
63 strd r2, r3, [lr, #-8]
64 bne L0 ; goto beginning of loop
65 L1
66 pop {r4, pc}
67
68 L2
69 subs r4, r1, lr
70 L3
71 adds r4, r4, #16
72 subs r1, r1, #8
73 cmp r4, #4 ; between 4 and 15 bytes?
74 blt L4
75 cmp r4, #8 ; between 8 and 15 bytes?
76 str r2, [lr, #-16] ; overlapping store of 4 + (4 + 4) + 4 bytes
77 itt gt
78 strgt r3, [lr, #-12]
79 strgt r2, [r1]
80 str r3, [r1, #4]
81 pop {r4, pc}
82
83 L4
84 cmp r4, #2 ; 2 or 3 bytes?
85 strb r2, [lr, #-16] ; store 1 byte
86 it ge
87 strhge r2, [r1, #6] ; store 2 bytes
88 pop {r4, pc}
89
90 END