3 ;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 ;This program and the accompanying materials
5 ;are licensed and made available under the terms and conditions of the BSD License
6 ;which accompanies this distribution. The full text of the license may be found at
7 ;http://opensource.org/licenses/bsd-license.php
9 ;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 ; This is the code that supports IA32-optimized ZeroMem service
21 ;---------------------------------------------------------------------------
27 ;---------------------------------------------------------------------------
29 ;EfiCommonLibZeroMem (
35 ;Input: VOID *Buffer - Pointer to buffer to clear
36 ; UINTN Count - Number of bytes to clear
44 ;Description: This function is an optimized zero-memory function.
46 ;Notes: This function tries to zero memory 8 bytes at a time. As a result,
47 ; it first picks up any misaligned bytes, then words, before getting
48 ; in the main loop that does the 8-byte clears.
51 EfiCommonLibZeroMem PROC
55 push ecx ; Reserve space for local variable MmxSave
59 mov ecx, [ebp + 0Ch] ; Count
60 mov edi, [ebp + 8]; Buffer
62 ; Pick up misaligned start bytes (get pointer 4-byte aligned)
65 and al, 3 ; check lower 2 bits of address
67 je _ZeroBlocks ; already aligned?
71 ; Clear the byte memory location
77 jmp _StartByteZero ; back to top of loop
81 ; Compute how many 64-byte blocks we can clear
83 shr ecx, 6 ; convert to 64-byte count
84 shl ecx, 6 ; convert back to bytes
85 sub edx, ecx ; subtract from the original count
86 shr ecx, 6 ; and this is how many 64-byte blocks
88 ; If no 64-byte blocks, then skip
93 movq [ebp - 8], mm0 ; Save mm0 to MmxSave
95 pxor mm0, mm0 ; Clear mm0
98 movq QWORD PTR ds:[edi], mm0
99 movq QWORD PTR ds:[edi+8], mm0
100 movq QWORD PTR ds:[edi+16], mm0
101 movq QWORD PTR ds:[edi+24], mm0
102 movq QWORD PTR ds:[edi+32], mm0
103 movq QWORD PTR ds:[edi+40], mm0
104 movq QWORD PTR ds:[edi+48], mm0
105 movq QWORD PTR ds:[edi+56], mm0
112 movq mm0, [ebp - 8] ; Restore mm0 from MmxSave
113 emms ; Exit MMX Instruction
116 ; Zero out as many DWORDS as possible
123 ; Zero out remaining as bytes
134 EfiCommonLibZeroMem ENDP