clean up all of eight BaseMemoryLib instances in MdePkg with the following updates:

1.	Remove .intel_syntax directives in GCC assembly files. All these assembly files have been updated to use the preferred syntax for GAS
2.	Correct the incorrect comments for internal worker functions for SetMemXX() and ScanMemXX(). The Length parameter is actually the counter of 16-bit, 32-bit or 64-bit value. 
3.	Simplify the logic in ZeroMemoryWrapper.c for BaseMemoryLibOptPei instance to remove the conditional statement for zero length. This logic is already covered by worker function InternalMemZeroMem(). 
4.	Cleanup all the Wrapper C files in BaseMemoryLib instances. They are supposed to be shared by all these 8 BaseMemoryLib instances, but are out-of-sync after some maintenance. This patch re-syncs them and makes them exactly the same.
5.	Cleanup MemLibInternal.h so that it is shared by 6 BaseMemoryLib instance except for PeiMemoryLib and UefiMemoryLib.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9041 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2009-08-11 15:32:16 +00:00
parent ba19956ac3
commit 1fef058f4b
162 changed files with 1087 additions and 1252 deletions

View File

@@ -9,9 +9,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -8,10 +8,8 @@
BaseMemoryLibRepStr
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -30,13 +28,12 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
/**
Copy Length bytes from Source to Destination.
@param DestinationBuffer Target of copy
@param SourceBuffer Place to copy from
@param Length Number of bytes to copy
@param SourceBuffer Place to copy from
@param Length Number of bytes to copy
@return Destination
@@ -52,9 +49,9 @@ InternalMemCopyMem (
/**
Set Buffer to Value for Size bytes.
@param Buffer Memory to set.
@param Length Number of bytes to set
@param Value Value of the set operation.
@param Buffer Memory to set.
@param Length Number of bytes to set
@param Value Value of the set operation.
@return Buffer
@@ -71,7 +68,7 @@ InternalMemSetMem (
Fills a target buffer with a 16-bit value, and returns the target buffer.
@param Buffer Pointer to the target buffer to fill.
@param Length Number of bytes in Buffer to fill.
@param Length Count of 16-bit value to fill.
@param Value Value with which to fill Length bytes of Buffer.
@return Buffer
@@ -89,7 +86,7 @@ InternalMemSetMem16 (
Fills a target buffer with a 32-bit value, and returns the target buffer.
@param Buffer Pointer to the target buffer to fill.
@param Length Number of bytes in Buffer to fill.
@param Length Count of 32-bit value to fill.
@param Value Value with which to fill Length bytes of Buffer.
@return Buffer
@@ -107,7 +104,7 @@ InternalMemSetMem32 (
Fills a target buffer with a 64-bit value, and returns the target buffer.
@param Buffer Pointer to the target buffer to fill.
@param Length Number of bytes in Buffer to fill.
@param Length Count of 64-bit value to fill.
@param Value Value with which to fill Length bytes of Buffer.
@return Buffer
@@ -163,7 +160,7 @@ InternalMemCompareMem (
matching 8-bit value in the target buffer.
@param Buffer Pointer to the target buffer to scan.
@param Length Number of bytes in Buffer to scan. Must be non-zero.
@param Length Count of 8-bit value to scan. Must be non-zero.
@param Value Value to search for in the target buffer.
@return Pointer to the first occurrence or NULL if not found.
@@ -182,7 +179,7 @@ InternalMemScanMem8 (
matching 16-bit value in the target buffer.
@param Buffer Pointer to the target buffer to scan.
@param Length Number of bytes in Buffer to scan. Must be non-zero.
@param Length Count of 16-bit value to scan. Must be non-zero.
@param Value Value to search for in the target buffer.
@return Pointer to the first occurrence or NULL if not found.
@@ -201,7 +198,7 @@ InternalMemScanMem16 (
matching 32-bit value in the target buffer.
@param Buffer Pointer to the target buffer to scan.
@param Length Number of bytes in Buffer to scan. Must be non-zero.
@param Length Count of 32-bit value to scan. Must be non-zero.
@param Value Value to search for in the target buffer.
@return Pointer to the first occurrence or NULL if not found.
@@ -220,7 +217,7 @@ InternalMemScanMem32 (
matching 64-bit value in the target buffer.
@param Buffer Pointer to the target buffer to scan.
@param Length Number of bytes in Buffer to scan. Must be non-zero.
@param Length Count of 64-bit value to scan. Must be non-zero.
@param Value Value to search for in the target buffer.
@return Pointer to the first occurrence or NULL if not found.

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -9,9 +9,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -9,9 +9,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -22,9 +22,6 @@
**/
#include "MemLibInternals.h"
/**

View File

@@ -9,9 +9,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -22,9 +22,6 @@
**/
#include "MemLibInternals.h"
/**

View File

@@ -9,9 +9,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -22,9 +22,6 @@
**/
#include "MemLibInternals.h"
/**

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008, Intel Corporation<BR>
Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -42,19 +42,18 @@
# IN UINTN Length
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemCompareMem)
ASM_PFX(InternalMemCompareMem):
push rsi
push rdi
mov rsi, rcx
mov rdi, rdx
mov rcx, r8
pushq %rsi
pushq %rdi
movq %rcx, %rsi
movq %rdx, %rdi
movq %r8, %rcx
repe cmpsb
movzx rax, byte ptr [rsi - 1]
movzx rdx, byte ptr [rdi - 1]
sub rax, rdx
pop rdi
pop rsi
movzbq -1(%rsi) , %rax
movzbq -1(%rdi) , %rdx
subq %rdx, %rax
popq %rdi
popq %rsi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -34,51 +34,50 @@
# IN UINTN Count
# )
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
ASM_PFX(InternalMemCopyMem):
push rsi
push rdi
mov rsi, rdx # rsi <- Source
mov rdi, rcx # rdi <- Destination
lea r9, [rsi + r8 - 1] # r9 <- Last byte of Source
cmp rsi, rdi
mov rax, rdi # rax <- Destination as return value
pushq %rsi
pushq %rdi
movq %rdx, %rsi # rsi <- Source
movq %rcx, %rdi # rdi <- Destination
leaq -1(%rsi, %r8,), %r9 # r9 <- Last byte of Source
cmpq %rdi, %rsi
movq %rdi, %rax # rax <- Destination as return value
jae L0 # Copy forward if Source > Destination
cmp r9, rdi # Overlapped?
cmpq %rdi, %r9 # Overlapped?
jae L_CopyBackward # Copy backward if overlapped
L0:
xor rcx, rcx
sub rcx, rdi # rcx <- -rdi
and rcx, 15 # rcx + rsi should be 16 bytes aligned
xorq %rcx, %rcx
subq %rdi, %rcx # rcx <- -rdi
andq $15, %rcx # rcx + rsi should be 16 bytes aligned
jz L1 # skip if rcx == 0
cmp rcx, r8
cmova rcx, r8
sub r8, rcx
cmpq %r8, %rcx
cmova %r8, %rcx
subq %rcx, %r8
rep movsb
L1:
mov rcx, r8
and r8, 15
shr rcx, 4 # rcx <- # of DQwords to copy
movq %r8, %rcx
andq $15, %r8
shrq $4, %rcx # rcx <- # of DQwords to copy
jz L_CopyBytes
movdqa [rsp + 0x18], xmm0 # save xmm0 on stack
movdqa %xmm0, 0x18(%rsp) # save xmm0 on stack
L2:
movdqu xmm0, [rsi] # rsi may not be 16-byte aligned
movntdq [rdi], xmm0 # rdi should be 16-byte aligned
add rsi, 16
add rdi, 16
movdqu (%rsi), %xmm0 # rsi may not be 16-byte aligned
movntdq %xmm0, (%rdi) # rdi should be 16-byte aligned
addq $16, %rsi
addq $16, %rdi
loop L2
mfence
movdqa xmm0, [rsp + 0x18] # restore xmm0
movdqa 0x18(%rsp), %xmm0 # restore xmm0
jmp L_CopyBytes # copy remaining bytes
L_CopyBackward:
mov rsi, r9 # rsi <- Last byte of Source
lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination
movq %r9, %rsi # rsi <- Last byte of Source
leaq -1(%rdi, %r8,), %rdi # rdi <- Last byte of Destination
std
L_CopyBytes:
mov rcx, r8
movq %r8, %rcx
rep movsb
cld
pop rdi
pop rsi
popq %rdi
popq %rsi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -42,16 +42,15 @@
# IN UINT16 Value
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemScanMem16)
ASM_PFX(InternalMemScanMem16):
push rdi
mov rdi, rcx
mov rax, r8
mov rcx, rdx
pushq %rdi
movq %rcx, %rdi
movq %rdx, %rcx
movq %r8, %rax
repne scasw
lea rax, [rdi - 2]
cmovnz rax, rcx
pop rdi
leaq -2(%rdi), %rax
cmovnz %rcx, %rax # set rax to 0 if not found
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -37,21 +37,20 @@
# CONST VOID *
# EFIAPI
# InternalMemScanMem32 (
# IN CONST VOID *Buffer,
# IN CONST VOID *Buffer,
# IN UINTN Length,
# IN UINT32 Value
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemScanMem32)
ASM_PFX(InternalMemScanMem32):
push rdi
mov rdi, rcx
mov rax, r8
mov rcx, rdx
repne scasd
lea rax, [rdi - 4]
cmovnz rax, rcx
pop rdi
pushq %rdi
movq %rcx, %rdi
movq %rdx, %rcx
movq %r8, %rax
repne scasl
leaq -4(%rdi), %rax
cmovnz %rcx, %rax # set rax to 0 if not found
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -37,21 +37,20 @@
# CONST VOID *
# EFIAPI
# InternalMemScanMem64 (
# IN CONST VOID *Buffer,
# IN CONST VOID *Buffer,
# IN UINTN Length,
# IN UINT64 Value
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemScanMem64)
ASM_PFX(InternalMemScanMem64):
push rdi
mov rdi, rcx
mov rax, r8
mov rcx, rdx
pushq %rdi
movq %rcx, %rdi
movq %rdx, %rcx
movq %r8, %rax
repne scasq
lea rax, [rdi - 8]
cmovnz rax, rcx
pop rdi
leaq -8(%rdi), %rax
cmovnz %rcx, %rax # set rax to 0 if not found
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -42,16 +42,15 @@
# IN UINT8 Value
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemScanMem8)
ASM_PFX(InternalMemScanMem8):
push rdi
mov rdi, rcx
mov rcx, rdx
mov rax, r8
pushq %rdi
movq %rcx, %rdi
movq %rdx, %rcx
movq %r8, %rax
repne scasb
lea rax, [rdi - 1]
cmovnz rax, rcx # set rax to 0 if not found
pop rdi
leaq -1(%rdi), %rax
cmovnz %rcx, %rax # set rax to 0 if not found
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -34,40 +34,39 @@
# IN UINT8 Value
# )
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem)
ASM_PFX(InternalMemSetMem):
push rdi
mov rdi, rcx # rdi <- Buffer
mov al, r8b # al <- Value
mov r9, rdi # r9 <- Buffer as return value
xor rcx, rcx
sub rcx, rdi
and rcx, 15 # rcx + rdi aligns on 16-byte boundary
pushq %rdi
movq %rcx, %rdi # rdi <- Buffer
movb %r8b, %al # al <- Value
movq %rdi, %r9 # r9 <- Buffer as return value
xorq %rcx, %rcx
subq %rdi, %rcx
andq $15, %rcx # rcx + rdi aligns on 16-byte boundary
jz L0
cmp rcx, rdx
cmova rcx, rdx
sub rdx, rcx
cmpq %rdx, %rcx
cmova %rdx, %rcx
subq %rcx, %rdx
rep stosb
L0:
mov rcx, rdx
and rdx, 15
shr rcx, 4
movq %rdx, %rcx
andq $15, %rdx
shrq $4, %rcx
jz L_SetBytes
mov ah, al # ax <- Value repeats twice
movdqa [rsp + 0x10], xmm0 # save xmm0
movd xmm0, eax # xmm0[0..16] <- Value repeats twice
pshuflw xmm0, xmm0, 0 # xmm0[0..63] <- Value repeats 8 times
movlhps xmm0, xmm0 # xmm0 <- Value repeats 16 times
movb %al, %ah # ax <- Value repeats twice
movdqa %xmm0, 0x10(%rsp) # save xmm0
movd %eax, %xmm0 # xmm0[0..16] <- Value repeats twice
pshuflw $0, %xmm0, %xmm0 # xmm0[0..63] <- Value repeats 8 times
movlhps %xmm0, %xmm0 # xmm0 <- Value repeats 16 times
L1:
movntdq [rdi], xmm0 # rdi should be 16-byte aligned
add rdi, 16
movntdq %xmm0, (%rdi) # rdi should be 16-byte aligned
add $16, %rdi
loop L1
mfence
movdqa xmm0, [rsp + 0x10] # restore xmm0
movdqa 0x10(%rsp), %xmm0 # restore xmm0
L_SetBytes:
mov ecx, edx # high 32 bits of rcx are always zero
movl %edx, %ecx # high 32 bits of rcx are always zero
rep stosb
mov rax, r9 # rax <- Return value
pop rdi
movq %r9, %rax # rax <- Return value
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -34,38 +34,37 @@
# IN UINT16 Value
# )
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
ASM_PFX(InternalMemSetMem16):
push rdi
mov rdi, rcx
mov r9, rdi
xor rcx, rcx
sub rcx, rdi
and rcx, 15
mov rax, r8
pushq %rdi
movq %rcx, %rdi
movq %rdi, %r9
xorq %rcx, %rcx
subq %rdi, %rcx
andq $15, %rcx
movq %r8, %rax
jz L0
shr rcx, 1
cmp rcx, rdx
cmova rcx, rdx
sub rdx, rcx
shrq $1, %rcx
cmpq %rdx, %rcx
cmova %rdx, %rcx
subq %rcx, %rdx
rep stosw
L0:
mov rcx, rdx
and edx, 7
shr rcx, 3
movq %rdx, %rcx
andl $7, %edx
shrq $3, %rcx
jz L_SetWords
movd xmm0, eax
pshuflw xmm0, xmm0, 0
movlhps xmm0, xmm0
movd %eax, %xmm0
pshuflw $0, %xmm0, %xmm0
movlhps %xmm0, %xmm0
L1:
movntdq [rdi], xmm0
add rdi, 16
movntdq %xmm0, (%rdi)
addq $16, %rdi
loop L1
mfence
L_SetWords:
mov ecx, edx
movl %edx, %ecx
rep stosw
mov rax, r9
pop rdi
movq %r9, %rax
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -34,37 +34,36 @@
# IN UINT32 Value
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
ASM_PFX(InternalMemSetMem32):
push rdi
mov rdi, rcx
mov r9, rdi
xor rcx, rcx
sub rcx, rdi
and rcx, 15
mov rax, r8
pushq %rdi
movq %rcx, %rdi
movq %rdi, %r9
xorq %rcx, %rcx
subq %rdi, %rcx
andq $15, %rcx
movq %r8, %rax
jz L0
shr rcx, 2
cmp rcx, rdx
cmova rcx, rdx
sub rdx, rcx
rep stosd
shrq $2, %rcx
cmpq %rdx, %rcx
cmova %rdx, %rcx
subq %rcx, %rdx
rep stosl
L0:
mov rcx, rdx
and edx, 3
shr rcx, 2
movq %rdx, %rcx
andl $3, %edx
shrq $2, %rcx
jz L_SetDwords
movd xmm0, eax
pshufd xmm0, xmm0, 0
movd %eax, %xmm0
pshufd $0, %xmm0, %xmm0
L1:
movntdq [rdi], xmm0
add rdi, 16
movntdq %xmm0, (%rdi)
addq $16, %rdi
loop L1
mfence
L_SetDwords:
mov ecx, edx
rep stosd
mov rax, r9
pop rdi
movl %edx, %ecx
rep stosl
movq %r9, %rax
popq %rdi
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -33,29 +33,28 @@
# IN UINT64 Value
# )
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
ASM_PFX(InternalMemSetMem64):
mov rax, rcx # rax <- Buffer
xchg rcx, rdx # rcx <- Count & rdx <- Buffer
test dl, 8
movq xmm0, r8
movq %rcx, %rax # rax <- Buffer
xchgq %rdx, %rcx # rcx <- Count & rdx <- Buffer
testb $8, %dl
movq %r8, %xmm0
jz L0
mov [rdx], r8
add rdx, 8
dec rcx
movq %r8, (%rdx)
addq $8, %rdx
decq %rcx
L0:
shr rcx, 1
shrq $1, %rcx
jz L_SetQwords
movlhps xmm0, xmm0
movlhps %xmm0, %xmm0
L1:
movntdq [rdx], xmm0
lea rdx, [rdx + 16]
movntdq %xmm0, (%rdx)
leaq 16(%rdx), %rdx
loop L1
mfence
L_SetQwords:
jnc L2
mov [rdx], r8
movq %r8, (%rdx)
L2:
ret

View File

@@ -3,7 +3,7 @@
#
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -32,35 +32,34 @@
# IN UINTN Count
# );
#------------------------------------------------------------------------------
.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
ASM_PFX(InternalMemZeroMem):
push rdi
mov rdi, rcx
xor rcx, rcx
xor eax, eax
sub rcx, rdi
and rcx, 15
mov r8, rdi
pushq %rdi
movq %rcx, %rdi
xorq %rcx, %rcx
xorl %eax, %eax
subq %rdi, %rcx
andq $15, %rcx
movq %rdi, %r8
jz L0
cmp rcx, rdx
cmova rcx, rdx
sub rdx, rcx
cmpq %rdx, %rcx
cmova %rdx, %rcx
subq %rcx, %rdx
rep stosb
L0:
mov rcx, rdx
and edx, 15
shr rcx, 4
movq %rdx, %rcx
andl $15, %edx
shrq $4, %rcx
jz L_ZeroBytes
pxor xmm0, xmm0
pxor %xmm0, %xmm0
L1:
movntdq [rdi], xmm0 # rdi should be 16-byte aligned
add rdi, 16
movntdq %xmm0, (%rdi) # rdi should be 16-byte aligned
addq $16, %rdi
loop L1
mfence
L_ZeroBytes:
mov ecx, edx
movl %edx, %ecx
rep stosb
mov rax, r8
pop rdi
movq %r8, %rax
popq %rdi
ret

View File

@@ -10,9 +10,9 @@
BaseMemoryLibOptDxe
BaseMemoryLibOptPei
PeiMemoryLib
DxeMemoryLib
UefiMemoryLib
Copyright (c) 2006 - 2008 , Intel Corporation<BR>
Copyright (c) 2006 - 2009 , Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at