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