]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / Arm / SetMem.S
CommitLineData
a37f6605
AB
1#------------------------------------------------------------------------------\r
2#\r
3# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
4#\r
9344f092 5# SPDX-License-Identifier: BSD-2-Clause-Patent\r
a37f6605
AB
6#\r
7#------------------------------------------------------------------------------\r
8\r
9 .text\r
10 .thumb\r
11 .syntax unified\r
12 .align 5\r
decaac5d 13 .type ASM_PFX(InternalMemSetMem16), %function\r
a37f6605
AB
14ASM_GLOBAL ASM_PFX(InternalMemSetMem16)\r
15ASM_PFX(InternalMemSetMem16):\r
16 uxth r2, r2\r
8b4ca351 17 lsl r1, r1, #1\r
a37f6605 18 orr r2, r2, r2, lsl #16\r
8b4ca351 19 b 0f\r
a37f6605 20\r
decaac5d 21 .type ASM_PFX(InternalMemSetMem32), %function\r
a37f6605
AB
22ASM_GLOBAL ASM_PFX(InternalMemSetMem32)\r
23ASM_PFX(InternalMemSetMem32):\r
8b4ca351
AB
24 lsl r1, r1, #2\r
25 b 0f\r
a37f6605 26\r
decaac5d 27 .type ASM_PFX(InternalMemSetMem64), %function\r
a37f6605
AB
28ASM_GLOBAL ASM_PFX(InternalMemSetMem64)\r
29ASM_PFX(InternalMemSetMem64):\r
8b4ca351
AB
30 lsl r1, r1, #3\r
31 b 1f\r
32\r
33 .align 5\r
decaac5d 34 .type ASM_PFX(InternalMemSetMem), %function\r
8b4ca351
AB
35ASM_GLOBAL ASM_PFX(InternalMemSetMem)\r
36ASM_PFX(InternalMemSetMem):\r
37 uxtb r2, r2\r
38 orr r2, r2, r2, lsl #8\r
39 orr r2, r2, r2, lsl #16\r
40 b 0f\r
41\r
decaac5d 42 .type ASM_PFX(InternalMemZeroMem), %function\r
8b4ca351
AB
43ASM_GLOBAL ASM_PFX(InternalMemZeroMem)\r
44ASM_PFX(InternalMemZeroMem):\r
45 movs r2, #0\r
460: mov r3, r2\r
47\r
481: push {r4, lr}\r
a37f6605
AB
49 cmp r1, #16 // fewer than 16 bytes of input?\r
50 add r1, r1, r0 // r1 := dst + length\r
51 add lr, r0, #16\r
52 blt 2f\r
53 bic lr, lr, #15 // align output pointer\r
54\r
55 str r2, [r0] // potentially unaligned store of 4 bytes\r
56 str r3, [r0, #4] // potentially unaligned store of 4 bytes\r
57 str r2, [r0, #8] // potentially unaligned store of 4 bytes\r
58 str r3, [r0, #12] // potentially unaligned store of 4 bytes\r
59 beq 1f\r
60\r
610: add lr, lr, #16 // advance the output pointer by 16 bytes\r
62 subs r4, r1, lr // past the output?\r
63 blt 3f // break out of the loop\r
64 strd r2, r3, [lr, #-16] // aligned store of 16 bytes\r
65 strd r2, r3, [lr, #-8]\r
66 bne 0b // goto beginning of loop\r
671: pop {r4, pc}\r
68\r
692: subs r4, r1, lr\r
703: adds r4, r4, #16\r
71 subs r1, r1, #8\r
72 cmp r4, #4 // between 4 and 15 bytes?\r
73 blt 4f\r
74 cmp r4, #8 // between 8 and 15 bytes?\r
eab26788
AB
75 sub r4, lr, #16\r
76 str r2, [r4] // overlapping store of 4 + (4 + 4) + 4 bytes\r
77 it gt\r
78 strgt.n r3, [r4, #4]\r
79 it gt\r
80 strgt.n r2, [r1]\r
a37f6605
AB
81 str r3, [r1, #4]\r
82 pop {r4, pc}\r
83\r
844: cmp r4, #2 // 2 or 3 bytes?\r
85 strb r2, [lr, #-16] // store 1 byte\r
86 it ge\r
eab26788 87 strhge.n r2, [r1, #6] // store 2 bytes\r
a37f6605 88 pop {r4, pc}\r