]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibSse2/X64/SetMem32.nasm
BaseMemoryLibSse2: Take advantage of write combining buffers
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / X64 / SetMem32.nasm
CommitLineData
1380b8d0
JJ
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
9344f092 4; SPDX-License-Identifier: BSD-2-Clause-Patent\r
1380b8d0
JJ
5;\r
6; Module Name:\r
7;\r
8; SetMem32.nasm\r
9;\r
10; Abstract:\r
11;\r
12; SetMem32 function\r
13;\r
14; Notes:\r
15;\r
16;------------------------------------------------------------------------------\r
17\r
18 DEFAULT REL\r
19 SECTION .text\r
20\r
21;------------------------------------------------------------------------------\r
22; VOID *\r
23; InternalMemSetMem32 (\r
24; IN VOID *Buffer,\r
25; IN UINTN Count,\r
26; IN UINT8 Value\r
27; )\r
28;------------------------------------------------------------------------------\r
29global ASM_PFX(InternalMemSetMem32)\r
30ASM_PFX(InternalMemSetMem32):\r
31 push rdi\r
32 mov rdi, rcx\r
33 mov r9, rdi\r
34 xor rcx, rcx\r
35 sub rcx, rdi\r
36 and rcx, 15\r
37 mov rax, r8\r
38 jz .0\r
39 shr rcx, 2\r
40 cmp rcx, rdx\r
41 cmova rcx, rdx\r
42 sub rdx, rcx\r
43 rep stosd\r
44.0:\r
45 mov rcx, rdx\r
d25fd871
CJ
46 and edx, 15\r
47 shr rcx, 4\r
1380b8d0
JJ
48 jz @SetDwords\r
49 movd xmm0, eax\r
50 pshufd xmm0, xmm0, 0\r
51.1:\r
52 movntdq [rdi], xmm0\r
d25fd871
CJ
53 movntdq [rdi + 16], xmm0\r
54 movntdq [rdi + 32], xmm0\r
55 movntdq [rdi + 48], xmm0\r
56 add rdi, 64\r
1380b8d0
JJ
57 loop .1\r
58 mfence\r
59@SetDwords:\r
60 mov ecx, edx\r
61 rep stosd\r
62 mov rax, r9\r
63 pop rdi\r
64 ret\r
65\r