]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptDxe/Arm/SetMem.S
MdePkg/BaseMemoryLibOptDxe: add accelerated ARM routines
[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
5# This program and the accompanying materials are licensed and made available\r
6# under the terms and conditions of the BSD License which accompanies this\r
7# distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13#------------------------------------------------------------------------------\r
14\r
15 .text\r
16 .thumb\r
17 .syntax unified\r
18 .align 5\r
19ASM_GLOBAL ASM_PFX(InternalMemZeroMem)\r
20ASM_PFX(InternalMemZeroMem):\r
21 movs r2, #0\r
22\r
23ASM_GLOBAL ASM_PFX(InternalMemSetMem)\r
24ASM_PFX(InternalMemSetMem):\r
25 uxtb r2, r2\r
26 orr r2, r2, r2, lsl #8\r
27\r
28ASM_GLOBAL ASM_PFX(InternalMemSetMem16)\r
29ASM_PFX(InternalMemSetMem16):\r
30 uxth r2, r2\r
31 orr r2, r2, r2, lsl #16\r
32\r
33ASM_GLOBAL ASM_PFX(InternalMemSetMem32)\r
34ASM_PFX(InternalMemSetMem32):\r
35 mov r3, r2\r
36\r
37ASM_GLOBAL ASM_PFX(InternalMemSetMem64)\r
38ASM_PFX(InternalMemSetMem64):\r
39 push {r4, lr}\r
40 cmp r1, #16 // fewer than 16 bytes of input?\r
41 add r1, r1, r0 // r1 := dst + length\r
42 add lr, r0, #16\r
43 blt 2f\r
44 bic lr, lr, #15 // align output pointer\r
45\r
46 str r2, [r0] // potentially unaligned store of 4 bytes\r
47 str r3, [r0, #4] // potentially unaligned store of 4 bytes\r
48 str r2, [r0, #8] // potentially unaligned store of 4 bytes\r
49 str r3, [r0, #12] // potentially unaligned store of 4 bytes\r
50 beq 1f\r
51\r
520: add lr, lr, #16 // advance the output pointer by 16 bytes\r
53 subs r4, r1, lr // past the output?\r
54 blt 3f // break out of the loop\r
55 strd r2, r3, [lr, #-16] // aligned store of 16 bytes\r
56 strd r2, r3, [lr, #-8]\r
57 bne 0b // goto beginning of loop\r
581: pop {r4, pc}\r
59\r
602: subs r4, r1, lr\r
613: adds r4, r4, #16\r
62 subs r1, r1, #8\r
63 cmp r4, #4 // between 4 and 15 bytes?\r
64 blt 4f\r
65 cmp r4, #8 // between 8 and 15 bytes?\r
66 str r2, [lr, #-16] // overlapping store of 4 + (4 + 4) + 4 bytes\r
67 itt gt\r
68 strgt r3, [lr, #-12]\r
69 strgt r2, [r1]\r
70 str r3, [r1, #4]\r
71 pop {r4, pc}\r
72\r
734: cmp r4, #2 // 2 or 3 bytes?\r
74 strb r2, [lr, #-16] // store 1 byte\r
75 it ge\r
76 strhge r2, [r1, #6] // store 2 bytes\r
77 pop {r4, pc}\r