summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseMemoryLibOptDxe/X64
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-08-11 15:32:16 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-08-11 15:32:16 +0000
commit1fef058f4b8fefc455bb171e4908c3e835b1b492 (patch)
treea61203bc9df33742251d8496b9b481399677caf1 /MdePkg/Library/BaseMemoryLibOptDxe/X64
parentba19956ac3c600eaeff1c90556457105032218d8 (diff)
downloadedk2-platforms-1fef058f4b8fefc455bb171e4908c3e835b1b492.tar.xz
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
Diffstat (limited to 'MdePkg/Library/BaseMemoryLibOptDxe/X64')
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/CompareMem.S25
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/CopyMem.S61
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem16.S19
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem32.S19
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem64.S19
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem8.S23
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem.S43
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem16.S15
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem32.S17
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem64.S15
-rw-r--r--MdePkg/Library/BaseMemoryLibOptDxe/X64/ZeroMem.S23
11 files changed, 134 insertions, 145 deletions
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/CompareMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/CompareMem.S
index c207db7dda..4f73686f30 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/CompareMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/CompareMem.S
@@ -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
@@ -41,20 +41,19 @@
# IN CONST VOID *SourceBuffer,
# 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
+ sub %dl, %al
+ popq %rdi
+ popq %rsi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/CopyMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/CopyMem.S
index c05e50aa9d..a516df6122 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/CopyMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/CopyMem.S
@@ -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,51 +33,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?
- jae L_CopyBackward # Copy backward if 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
+ movdqu %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
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem16.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem16.S
index 140b0a40e5..24055dc8c0 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem16.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem16.S
@@ -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
# InternalMemScanMem16 (
-# IN CONST VOID *Buffer,
+# IN CONST VOID *Buffer,
# IN UINTN Length,
# 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 %r8, %rax
+ movq %rdx, %rcx
repne scasw
- lea rax, [rdi - 2]
- cmovnz rax, rcx
- pop rdi
+ leaq -2(%rdi), %rax
+ cmovnz %rcx, %rax
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem32.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem32.S
index 9420725d5e..b7a5884966 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem32.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem32.S
@@ -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 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 %r8, %rax
+ movq %rdx, %rcx
+ repne scasl
+ leaq -4(%rdi), %rax
+ cmovnz %rcx, %rax
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem64.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem64.S
index d39f17fac3..c1a9d4b253 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem64.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem64.S
@@ -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,20 +37,19 @@
# 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 %r8, %rax
+ movq %rdx, %rcx
repne scasq
- lea rax, [rdi - 8]
- cmovnz rax, rcx
- pop rdi
+ leaq -8(%rdi), %rax
+ cmovnz %rcx, %rax
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem8.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem8.S
index 74667a6200..d2d8bb5d9b 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem8.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ScanMem8.S
@@ -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
# InternalMemScanMem8 (
-# IN CONST VOID *Buffer,
-# IN UINTN Length,
-# IN UINT8 Value
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# 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
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem.S
index c7c07ad309..fc8efdeaec 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# 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
@@ -29,30 +29,29 @@
# IN UINT8 Value
# )
#------------------------------------------------------------------------------
-.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem)
ASM_PFX(InternalMemSetMem):
- push rdi
- push rbx
- push rcx # push Buffer
- mov rax, r8 # rax = Value
- and rax, 0xff # rax = lower 8 bits of r8, upper 56 bits are 0
- mov ah, al # ah = al
- mov bx, ax # bx = ax
- shl rax, 0x10 # rax = ax << 16
- mov ax, bx # ax = bx
- mov rbx, rax # ebx = eax
- shl rax, 0x20 # rax = rax << 32
- or rax, rbx # eax = ebx
- mov rdi, rcx # rdi = Buffer
- mov rcx, rdx # rcx = Count
- shr rcx, 3 # rcx = rcx / 8
+ pushq %rdi
+ pushq %rbx
+ pushq %rcx # push Buffer
+ movq %r8, %rax # rax = Value
+ andq $0xff, %rax # rax = lower 8 bits of r8, upper 56 bits are 0
+ movb %al, %ah # ah = al
+ movw %ax, %bx # bx = ax
+ shlq $0x10, %rax # rax = ax << 16
+ movw %bx, %ax # ax = bx
+ movq %rax, %rbx # ebx = eax
+ shlq $0x20, %rax # rax = rax << 32
+ orq %rbx, %rax # eax = ebx
+ movq %rcx, %rdi # rdi = Buffer
+ movq %rdx, %rcx # rcx = Count
+ shrq $3, %rcx # rcx = rcx / 8
cld
rep stosq
- mov rcx, rdx # rcx = rdx
- and rcx, 7 # rcx = rcx & 7
+ movq %rdx, %rcx # rcx = rdx
+ andq $7, %rcx # rcx = rcx & 7
rep stosb
- pop rax # rax = Buffer
- pop rbx
- pop rdi
+ popq %rax # rax = Buffer
+ popq %rbx
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem16.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem16.S
index c091131a75..af63e42b63 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem16.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem16.S
@@ -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,15 +34,14 @@
# IN UINT16 Value
# )
#------------------------------------------------------------------------------
-.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
ASM_PFX(InternalMemSetMem16):
- push rdi
- mov rdi, rcx
- mov rax, r8
- xchg rcx, rdx
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %r8, %rax
+ xchg %rdx, %rcx
rep stosw
- mov rax, rdx
- pop rdi
+ movq %rdx, %rax
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem32.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem32.S
index 9fbcdafcb4..93d705c674 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem32.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem32.S
@@ -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,15 +34,14 @@
# IN UINT32 Value
# );
#------------------------------------------------------------------------------
-.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
ASM_PFX(InternalMemSetMem32):
- push rdi
- mov rdi, rcx
- mov rax, r8
- xchg rcx, rdx
- rep stosd
- mov rax, rdx
- pop rdi
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %r8, %rax
+ xchgq %rdx, %rcx
+ rep stosl
+ movq %rdx, %rax
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem64.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem64.S
index c4f0b4685d..306077a1fa 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem64.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem64.S
@@ -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,15 +33,14 @@
# IN UINT64 Value
# )
#------------------------------------------------------------------------------
-.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
ASM_PFX(InternalMemSetMem64):
- push rdi
- mov rdi, rcx
- mov rax, r8
- xchg rcx, rdx
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %r8, %rax
+ xchg %rdx, %rcx
rep stosq
- mov rax, rdx
- pop rdi
+ movq %rdx, %rax
+ popq %rdi
ret
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ZeroMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ZeroMem.S
index 6cd1474420..49cef3878b 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/X64/ZeroMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/X64/ZeroMem.S
@@ -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,21 +32,20 @@
# IN UINTN Count
# );
#------------------------------------------------------------------------------
-.intel_syntax noprefix
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
ASM_PFX(InternalMemZeroMem):
- push rdi
- push rcx
- xor rax, rax
- mov rdi, rcx
- mov rcx, rdx
- shr rcx, 3
- and rdx, 7
+ pushq %rdi
+ pushq %rcx
+ xorq %rax, %rax
+ movq %rcx, %rdi
+ movq %rdx, %rcx
+ shrq $3, %rcx
+ andq $7, %rdx
cld
rep stosq
- mov rcx, rdx
+ movq %rdx, %rcx
rep stosb
- pop rax
- pop rdi
+ popq %rax
+ popq %rdi
ret