]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / Ia32 / EfiSetMem.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 EfiSetMem.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, 07h\r
68 test al, al\r
69 je _SetBlock\r
70 \r
71 mov eax, edi\r
72 shr eax, 3\r
73 inc eax\r
74 shl eax, 3\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, 6\r
88 test eax, eax\r
89 je _SetRemindingByte\r
90\r
91 shl eax, 6\r
92 sub edx, eax\r
93 shr eax, 6\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_B:\r
105 movq QWORD PTR ds:[edi], mm0\r
106 movq QWORD PTR ds:[edi+8], mm0\r
107 movq QWORD PTR ds:[edi+16], mm0\r
108 movq QWORD PTR ds:[edi+24], mm0\r
109 movq QWORD PTR ds:[edi+32], mm0\r
110 movq QWORD PTR ds:[edi+40], mm0\r
111 movq QWORD PTR ds:[edi+48], mm0\r
112 movq QWORD PTR ds:[edi+56], mm0\r
113 add edi, 64\r
114 dec eax\r
115 jnz _B\r
116 \r
117; Restore mm0\r
118 movq mm0, MmxSave\r
119 emms ; Exit MMX Instruction\r
120 \r
121_SetRemindingByte:\r
122 mov ecx, edx\r
123\r
124 mov eax, ebx\r
125 shl eax, 16\r
126 mov ax, bx\r
127 shr ecx, 2\r
128 rep stosd\r
129 \r
130 mov ecx, edx\r
131 and ecx, 3\r
132 rep stosb\r
133 \r
134 pop ebx\r
135\r
136_SetMemDone:\r
137\r
138 }\r
139}\r