3 #Copyright (c) 2006, Intel Corporation
4 #All rights reserved. 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
22 #---------------------------------------------------------------------------
28 #---------------------------------------------------------------------------
29 .globl ASM_PFX(EfiCommonLibZeroMem)
31 #EfiCommonLibZeroMem (
37 #Input: VOID *Buffer - Pointer to buffer to clear
38 # UINTN Count - Number of bytes to clear
46 #Description: This function is an optimized zero-memory function.
48 #Notes: This function tries to zero memory 8 bytes at a time. As a result,
49 # it first picks up any misaligned bytes, then words, before getting
50 # in the main loop that does the 8-byte clears.
53 ASM_PFX(EfiCommonLibZeroMem):
57 pushl %ecx # Reserve space for local variable MmxSave
61 movl 0xC(%ebp), %ecx # Count
62 movl 8(%ebp), %edi # Buffer
64 # Pick up misaligned start bytes (get pointer 4-byte aligned)
67 andb $3, %al # check lower 2 bits of address
69 je _ZeroBlocks # already aligned?
73 # Clear the byte memory location
79 jmp _StartByteZero # back to top of loop
83 # Compute how many 64-byte blocks we can clear
85 shrl $6, %ecx # convert to 64-byte count
86 shll $6, %ecx # convert back to bytes
87 subl %ecx, %edx # subtract from the original count
88 shrl $6, %ecx # and this is how many 64-byte blocks
90 # If no 64-byte blocks, then skip
95 movq %mm0, -8(%ebp) # Save mm0 to MmxSave
97 pxor %mm0, %mm0 # Clear mm0
100 movq %mm0, %ds:(%edi)
101 movq %mm0, %ds:8(%edi)
102 movq %mm0, %ds:16(%edi)
103 movq %mm0, %ds:24(%edi)
104 movq %mm0, %ds:32(%edi)
105 movq %mm0, %ds:40(%edi)
106 movq %mm0, %ds:48(%edi)
107 movq %mm0, %ds:56(%edi)
114 movq -8(%ebp), %mm0 # Restore mm0 from MmxSave
115 emms # Exit MMX Instruction
118 # Zero out as many DWORDS as possible
126 # Zero out remaining as bytes
138 #EfiCommonLibZeroMem ENDP