]>
Commit | Line | Data |
---|---|---|
b341712e | 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 | |
b341712e | 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 | #include "EfiBind.h"\r | |
22 | #---------------------------------------------------------------------------\r | |
23 | .686: \r | |
24 | #.MODEL flat,C\r | |
25 | .mmx: \r | |
26 | .code: \r | |
27 | \r | |
28 | #---------------------------------------------------------------------------\r | |
29 | .globl ASM_PFX(EfiCommonLibSetMem)\r | |
30 | \r | |
31 | #VOID\r | |
32 | #EfiCommonLibSetMem (\r | |
33 | # IN VOID *Buffer,\r | |
34 | # IN UINTN Count,\r | |
35 | # IN UINT8 Value\r | |
36 | # )\r | |
37 | #/*++\r | |
38 | #\r | |
39 | #Input: VOID *Buffer - Pointer to buffer to write\r | |
40 | # UINTN Count - Number of bytes to write\r | |
41 | # UINT8 Value - Value to write\r | |
42 | #\r | |
43 | #Output: None.\r | |
44 | #\r | |
45 | #Saves:\r | |
46 | #\r | |
47 | #Modifies:\r | |
48 | #\r | |
49 | #Description: This function is an optimized set-memory function.\r | |
50 | #\r | |
51 | #Notes: This function tries to set memory 8 bytes at a time. As a result, \r | |
52 | # it first picks up any misaligned bytes, then words, before getting \r | |
53 | # in the main loop that does the 8-byte clears.\r | |
54 | #\r | |
55 | #--*/\r | |
56 | ASM_PFX(EfiCommonLibSetMem):\r | |
57 | \r | |
58 | pushl %ebp\r | |
59 | movl %esp, %ebp\r | |
60 | subl $0x10, %esp # Reserve space for local variable UINT64 QWordValue @[ebp - 10H] & UINT64 MmxSave @[ebp - 18H]\r | |
61 | pushl %ebx\r | |
62 | pushl %edi\r | |
63 | \r | |
64 | movl 0xC(%ebp), %edx # Count\r | |
65 | testl %edx, %edx\r | |
66 | je _SetMemDone\r | |
67 | \r | |
68 | pushl %ebx\r | |
69 | \r | |
70 | movl 8(%ebp), %eax # Buffer\r | |
71 | movb 0x10(%ebp), %bl # Value\r | |
72 | movl %eax, %edi\r | |
73 | movb %bl, %bh\r | |
74 | \r | |
75 | cmpl $256, %edx\r | |
76 | jb _SetRemindingByte\r | |
77 | \r | |
78 | andb $0x7, %al\r | |
79 | testb %al, %al\r | |
80 | je _SetBlock\r | |
81 | \r | |
82 | movl %edi, %eax\r | |
83 | shrl $3, %eax\r | |
84 | incl %eax\r | |
85 | shll $3, %eax\r | |
86 | subl %edi, %eax\r | |
87 | cmpl %edx, %eax\r | |
88 | jnb _SetRemindingByte\r | |
89 | \r | |
90 | subl %eax, %edx\r | |
91 | movl %eax, %ecx\r | |
92 | \r | |
93 | movb %bl, %al\r | |
94 | rep\r | |
95 | stosb\r | |
96 | \r | |
97 | _SetBlock: \r | |
98 | movl %edx, %eax\r | |
99 | shrl $6, %eax\r | |
100 | testl %eax, %eax\r | |
101 | je _SetRemindingByte\r | |
102 | \r | |
103 | shll $6, %eax\r | |
104 | subl %eax, %edx\r | |
105 | shrl $6, %eax\r | |
106 | \r | |
107 | movw %bx, -0x10(%ebp) # QWordValue[0]\r | |
108 | movw %bx, -0x10+2(%ebp) # QWordValue[2]\r | |
109 | movw %bx, -0x10+4(%ebp) # QWordValue[4]\r | |
110 | movw %bx, -0x10+6(%ebp) # QWordValue[6]\r | |
111 | \r | |
112 | \r | |
113 | movq %mm0, -8(%ebp) # Save mm0 to MmxSave\r | |
114 | movq -0x10(%ebp), %mm0 # Load QWordValue to mm0\r | |
115 | \r | |
116 | _B: \r | |
117 | movq %mm0, %ds:(%edi)\r | |
118 | movq %mm0, %ds:8(%edi)\r | |
119 | movq %mm0, %ds:16(%edi)\r | |
120 | movq %mm0, %ds:24(%edi)\r | |
121 | movq %mm0, %ds:32(%edi)\r | |
122 | movq %mm0, %ds:40(%edi)\r | |
123 | movq %mm0, %ds:48(%edi)\r | |
124 | movq %mm0, %ds:56(%edi)\r | |
125 | addl $64, %edi\r | |
126 | decl %eax\r | |
127 | jnz _B\r | |
128 | \r | |
129 | # Restore mm0\r | |
130 | movq -8(%ebp), %mm0 # Restore MmxSave to mm0\r | |
131 | emms # Exit MMX Instruction\r | |
132 | \r | |
133 | _SetRemindingByte: \r | |
134 | movl %edx, %ecx\r | |
135 | \r | |
136 | movl %ebx, %eax\r | |
137 | shll $16, %eax\r | |
138 | movw %bx, %ax\r | |
139 | shrl $2, %ecx\r | |
140 | rep\r | |
141 | stosl\r | |
142 | \r | |
143 | movl %edx, %ecx\r | |
144 | andl $3, %ecx\r | |
145 | rep\r | |
146 | stosb\r | |
147 | \r | |
148 | popl %ebx\r | |
149 | \r | |
150 | _SetMemDone: \r | |
151 | \r | |
152 | popl %edi\r | |
153 | popl %ebx\r | |
154 | leave\r | |
155 | ret\r | |
156 | \r | |
157 | #EfiCommonLibSetMem ENDP\r | |
158 | \r |