]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / EfiSetMemSSE2.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 EfiSetMemSSE2.c\r
15\r
16Abstract:\r
17\r
18 This is the code that supports IA32-optimized SetMem service\r
19\r
20--*/\r
21\r
22#include "Tiano.h"\r
23\r
24VOID\r
25EfiCommonLibSetMem (\r
26 IN VOID *Buffer,\r
27 IN UINTN Count,\r
28 IN UINT8 Value\r
29 )\r
30/*++\r
31\r
32Input: VOID *Buffer - Pointer to buffer to write\r
33 UINTN Count - Number of bytes to write\r
34 UINT8 Value - Value to write\r
35\r
36Output: None.\r
37\r
38Saves:\r
39\r
40Modifies:\r
41\r
42Description: This function is an optimized set-memory function.\r
43\r
44Notes: This function tries to set memory 8 bytes at a time. As a result, \r
45 it first picks up any misaligned bytes, then words, before getting \r
46 in the main loop that does the 8-byte clears.\r
47\r
48--*/\r
49{\r
50 UINT64 QWordValue;\r
51 UINT64 MmxSave;\r
52 __asm {\r
53 mov edx, Count\r
54 test edx, edx\r
55 je _SetMemDone\r
56\r
57 push ebx\r
58 \r
59 mov eax, Buffer\r
60 mov bl, Value\r
61 mov edi, eax\r
62 mov bh, bl\r
63 \r
64 cmp edx, 256\r
65 jb _SetRemindingByte\r
66 \r
67 and al, 0fh\r
68 test al, al\r
69 je _SetBlock\r
70 \r
71 mov eax, edi\r
72 shr eax, 4\r
73 inc eax\r
74 shl eax, 4\r
75 sub eax, edi\r
76 cmp eax, edx\r
77 jnb _SetRemindingByte\r
78 \r
79 sub edx, eax\r
80 mov ecx, eax\r
81\r
82 mov al, bl\r
83 rep stosb\r
84\r
85_SetBlock:\r
86 mov eax, edx\r
87 shr eax, 7\r
88 test eax, eax\r
89 je _SetRemindingByte\r
90\r
91 shl eax, 7\r
92 sub edx, eax\r
93 shr eax, 7\r
94\r
95 mov WORD PTR QWordValue[0], bx\r
96 mov WORD PTR QWordValue[2], bx\r
97 mov WORD PTR QWordValue[4], bx\r
98 mov WORD PTR QWordValue[6], bx\r
99 \r
100 \r
101 movq MmxSave, mm0\r
102 movq mm0, QWordValue\r
103\r
104 movq2dq xmm1, mm0\r
105 pshufd xmm1, xmm1, 0\r
106\r
107_Loop:\r
108 movdqa OWORD PTR ds:[edi], xmm1\r
109 movdqa OWORD PTR ds:[edi+16], xmm1\r
110 movdqa OWORD PTR ds:[edi+32], xmm1\r
111 movdqa OWORD PTR ds:[edi+48], xmm1\r
112 movdqa OWORD PTR ds:[edi+64], xmm1\r
113 movdqa OWORD PTR ds:[edi+80], xmm1\r
114 movdqa OWORD PTR ds:[edi+96], xmm1\r
115 movdqa OWORD PTR ds:[edi+112], xmm1\r
116 add edi, 128\r
117 dec eax\r
118 jnz _Loop\r
119 \r
120; Restore mm0\r
121 movq mm0, MmxSave\r
122 emms ; Exit MMX Instruction\r
123 \r
124_SetRemindingByte:\r
125 mov ecx, edx\r
126\r
127 mov eax, ebx\r
128 shl eax, 16\r
129 mov ax, bx\r
130 shr ecx, 2\r
131 rep stosd\r
132 \r
133 mov ecx, edx\r
134 and ecx, 3\r
135 rep stosb\r
136 \r
137 pop ebx\r
138\r
139_SetMemDone:\r
140 }\r
141}\r