summaryrefslogtreecommitdiff
path: root/Core/MdePkg/Library/BaseMemoryLibMmx/X64
diff options
context:
space:
mode:
Diffstat (limited to 'Core/MdePkg/Library/BaseMemoryLibMmx/X64')
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.S59
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm54
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.S74
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm70
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.S56
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm53
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.S56
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm53
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.S55
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm53
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.S56
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm53
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.S61
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm58
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.S60
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm57
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.S55
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm53
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.S47
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm46
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.S57
-rw-r--r--Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm54
22 files changed, 1240 insertions, 0 deletions
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.S
new file mode 100644
index 0000000000..590240591b
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.S
@@ -0,0 +1,59 @@
+#
+# ConvertAsm.py: Automatically generated from CompareMem.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CompareMem.S
+#
+# Abstract:
+#
+# CompareMem function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances contain the same copy of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+# BaseMemoryLibOptDxe
+# BaseMemoryLibOptPei
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# INTN
+# EFIAPI
+# InternalMemCompareMem (
+# IN CONST VOID *DestinationBuffer,
+# IN CONST VOID *SourceBuffer,
+# IN UINTN Length
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemCompareMem)
+ASM_PFX(InternalMemCompareMem):
+ pushq %rsi
+ pushq %rdi
+ movq %rcx, %rsi
+ movq %rdx, %rdi
+ movq %r8, %rcx
+ repe cmpsb
+ movzbq -1(%rsi), %rax
+ movzbq -1(%rdi), %rdx
+ subq %rdx, %rax
+ popq %rdi
+ popq %rsi
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm
new file mode 100644
index 0000000000..0ef05b2fa2
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm
@@ -0,0 +1,54 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CompareMem.Asm
+;
+; Abstract:
+;
+; CompareMem function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+InternalMemCompareMem PROC USES rsi rdi
+ mov rsi, rcx
+ mov rdi, rdx
+ mov rcx, r8
+ repe cmpsb
+ movzx rax, byte ptr [rsi - 1]
+ movzx rdx, byte ptr [rdi - 1]
+ sub rax, rdx
+ ret
+InternalMemCompareMem ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.S
new file mode 100644
index 0000000000..1d87e2d63a
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.S
@@ -0,0 +1,74 @@
+#
+# ConvertAsm.py: Automatically generated from CopyMem.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CopyMem.S
+#
+# Abstract:
+#
+# CopyMem function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# VOID *
+# EFIAPI
+# InternalMemCopyMem (
+# IN VOID *Destination,
+# IN VOID *Source,
+# IN UINTN Count
+# )
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
+ASM_PFX(InternalMemCopyMem):
+ pushq %rsi
+ pushq %rdi
+ movq %rdx, %rsi # rsi <- Source
+ movq %rcx, %rdi # rdi <- Destination
+ leaq -1(%rsi, %r8,), %r9 # r9 <- End of Source
+ cmpq %rdi, %rsi
+ movq %rdi, %rax # rax <- Destination as return value
+ jae L0
+ cmpq %rdi, %r9
+ jae L_CopyBackward # Copy backward if overlapped
+L0:
+ movq %r8, %rcx
+ andq $7, %r8
+ shrq $3, %rcx # rcx <- # of Qwords to copy
+ jz L_CopyBytes
+ movd %mm0, %r10 # (Save mm0 in r10)
+L1:
+ movq (%rsi), %mm0
+ movntq %mm0, (%rdi)
+ addq $8, %rsi
+ addq $8, %rdi
+ loop L1
+ mfence
+ movd %r10, %mm0 # (Restore mm0)
+ jmp L_CopyBytes
+L_CopyBackward:
+ movq %r9, %rsi # rsi <- End of Source
+ leaq -1(%rdi, %r8,), %rdi # rdi <- End of Destination
+ std # set direction flag
+L_CopyBytes:
+ movq %r8, %rcx
+ rep movsb # Copy bytes backward
+ cld
+ popq %rdi
+ popq %rsi
+ ret
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm
new file mode 100644
index 0000000000..6e74985e35
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm
@@ -0,0 +1,70 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CopyMem.asm
+;
+; Abstract:
+;
+; CopyMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemCopyMem (
+; OUT VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+InternalMemCopyMem PROC USES rsi rdi
+ mov rsi, rdx ; rsi <- Source
+ mov rdi, rcx ; rdi <- Destination
+ lea r9, [rsi + r8 - 1] ; r9 <- End of Source
+ cmp rsi, rdi
+ mov rax, rdi ; rax <- Destination as return value
+ jae @F
+ cmp r9, rdi
+ jae @CopyBackward ; Copy backward if overlapped
+@@:
+ mov rcx, r8
+ and r8, 7
+ shr rcx, 3 ; rcx <- # of Qwords to copy
+ jz @CopyBytes
+ DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10)
+@@:
+ DB 0fh, 6fh, 06h ; movd mm0, [rsi]
+ DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
+ add rsi, 8
+ add rdi, 8
+ loop @B
+ mfence
+ DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0)
+ jmp @CopyBytes
+@CopyBackward:
+ mov rsi, r9 ; rsi <- End of Source
+ lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination
+ std ; set direction flag
+@CopyBytes:
+ mov rcx, r8
+ rep movsb ; Copy bytes backward
+ cld
+ ret
+InternalMemCopyMem ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.S
new file mode 100644
index 0000000000..8f1899606a
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.S
@@ -0,0 +1,56 @@
+#
+# ConvertAsm.py: Automatically generated from ScanMem16.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem16.S
+#
+# Abstract:
+#
+# ScanMem16 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances contain the same copy of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+# BaseMemoryLibOptDxe
+# BaseMemoryLibOptPei
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem16 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT16 Value
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemScanMem16)
+ASM_PFX(InternalMemScanMem16):
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %r8, %rax
+ movq %rdx, %rcx
+ repne scasw
+ leaq -2(%rdi), %rax
+ cmovnz %rcx, %rax
+ popq %rdi
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm
new file mode 100644
index 0000000000..a6114db134
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem16.Asm
+;
+; Abstract:
+;
+; ScanMem16 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem16 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasw
+ lea rax, [rdi - 2]
+ cmovnz rax, rcx
+ ret
+InternalMemScanMem16 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.S
new file mode 100644
index 0000000000..05b6f6489a
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.S
@@ -0,0 +1,56 @@
+#
+# ConvertAsm.py: Automatically generated from ScanMem32.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem32.S
+#
+# Abstract:
+#
+# ScanMem32 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances contain the same copy of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+# BaseMemoryLibOptDxe
+# BaseMemoryLibOptPei
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem32 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT32 Value
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemScanMem32)
+ASM_PFX(InternalMemScanMem32):
+ 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/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm
new file mode 100644
index 0000000000..40ff6c9e93
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem32.Asm
+;
+; Abstract:
+;
+; ScanMem32 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem32 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasd
+ lea rax, [rdi - 4]
+ cmovnz rax, rcx
+ ret
+InternalMemScanMem32 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.S
new file mode 100644
index 0000000000..dd7c1b8634
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.S
@@ -0,0 +1,55 @@
+#
+# ConvertAsm.py: Automatically generated from ScanMem64.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem64.S
+#
+# Abstract:
+#
+# ScanMem64 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances contain the same copy of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+# BaseMemoryLibOptDxe
+# BaseMemoryLibOptPei
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem64 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT64 Value
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemScanMem64)
+ASM_PFX(InternalMemScanMem64):
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %r8, %rax
+ movq %rdx, %rcx
+ repne scasq
+ leaq -8(%rdi), %rax
+ cmovnz %rcx, %rax
+ popq %rdi
+ ret
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm
new file mode 100644
index 0000000000..e78da7d019
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem64.Asm
+;
+; Abstract:
+;
+; ScanMem64 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem64 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasq
+ lea rax, [rdi - 8]
+ cmovnz rax, rcx
+ ret
+InternalMemScanMem64 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.S
new file mode 100644
index 0000000000..4f3b950a34
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.S
@@ -0,0 +1,56 @@
+#
+# ConvertAsm.py: Automatically generated from ScanMem8.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ScanMem8.S
+#
+# Abstract:
+#
+# ScanMem8 function
+#
+# Notes:
+#
+# The following BaseMemoryLib instances contain the same copy of this file:
+#
+# BaseMemoryLibRepStr
+# BaseMemoryLibMmx
+# BaseMemoryLibSse2
+# BaseMemoryLibOptDxe
+# BaseMemoryLibOptPei
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem8 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT8 Value
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemScanMem8)
+ASM_PFX(InternalMemScanMem8):
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %rdx, %rcx
+ movq %r8, %rax
+ repne scasb
+ leaq -1(%rdi), %rax
+ cmovnz %rcx, %rax # set rax to 0 if not found
+ popq %rdi
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm
new file mode 100644
index 0000000000..fee239701d
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem8.Asm
+;
+; Abstract:
+;
+; ScanMem8 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem8 PROC USES rdi
+ mov rdi, rcx
+ mov rcx, rdx
+ mov rax, r8
+ repne scasb
+ lea rax, [rdi - 1]
+ cmovnz rax, rcx ; set rax to 0 if not found
+ ret
+InternalMemScanMem8 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.S
new file mode 100644
index 0000000000..ad7131f300
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.S
@@ -0,0 +1,61 @@
+#
+# ConvertAsm.py: Automatically generated from SetMem.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem.S
+#
+# Abstract:
+#
+# SetMem function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# VOID *
+# EFIAPI
+# InternalMemSetMem (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT8 Value
+# )
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemSetMem)
+ASM_PFX(InternalMemSetMem):
+ push %rdi
+ movq %r8, %rax
+ movb %al, %ah
+ movd %rax, %mm0
+ movq %rcx, %r8
+ movq %r8, %rdi # rdi <- Buffer
+ movq %rdx, %rcx
+ andq $7, %rdx
+ shrq $3, %rcx
+ jz L_SetBytes
+ .byte 0x0f, 0x70, 0x0C0, 0x00
+L0:
+ movntq %mm0, (%rdi)
+ addq $8, %rdi
+ loop L0
+ mfence
+L_SetBytes:
+ movl %edx, %ecx
+ rep stosb
+ movq %r8, %rax
+ pop %rdi
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm
new file mode 100644
index 0000000000..9ff949cdd2
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm
@@ -0,0 +1,58 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem.asm
+;
+; Abstract:
+;
+; SetMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem (
+; OUT VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemSetMem PROC USES rdi
+ mov rax, r8
+ mov ah, al
+ DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax
+ mov r8, rcx
+ mov rdi, r8 ; rdi <- Buffer
+ mov rcx, rdx
+ and edx, 7
+ shr rcx, 3
+ jz @SetBytes
+ DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
+@@:
+ DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
+ add rdi, 8
+ loop @B
+ mfence
+@SetBytes:
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+ ret
+InternalMemSetMem ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.S
new file mode 100644
index 0000000000..c947afd370
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.S
@@ -0,0 +1,60 @@
+#
+# ConvertAsm.py: Automatically generated from SetMem16.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem16.S
+#
+# Abstract:
+#
+# SetMem16 function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# VOID *
+# EFIAPI
+# InternalMemSetMem16 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT16 Value
+# )
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
+ASM_PFX(InternalMemSetMem16):
+ pushq %rdi
+ movq %r8, %rax
+ movd %rax, %mm0
+ movq %rcx, %r8
+ movq %r8, %rdi
+ movq %rdx, %rcx
+ andl $3, %edx
+ shrq $2, %rcx
+ jz L_SetWords
+ .byte 0x0f, 0x70, 0x0C0, 0x00
+L0:
+ movntq %mm0, (%rdi)
+ addq $8, %rdi
+ loop L0
+ mfence
+L_SetWords:
+ movl %edx, %ecx
+ rep stosw
+ movq %r8, %rax
+ popq %rdi
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm
new file mode 100644
index 0000000000..fbd98b0fe9
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm
@@ -0,0 +1,57 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem16.asm
+;
+; Abstract:
+;
+; SetMem16 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem16 (
+; OUT VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemSetMem16 PROC USES rdi
+ mov rax, r8
+ DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax
+ mov r8, rcx
+ mov rdi, r8
+ mov rcx, rdx
+ and edx, 3
+ shr rcx, 2
+ jz @SetWords
+ DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
+@@:
+ DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
+ add rdi, 8
+ loop @B
+ mfence
+@SetWords:
+ mov ecx, edx
+ rep stosw
+ mov rax, r8
+ ret
+InternalMemSetMem16 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.S
new file mode 100644
index 0000000000..4ab8e3a21d
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.S
@@ -0,0 +1,55 @@
+#
+# ConvertAsm.py: Automatically generated from SetMem32.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem32.S
+#
+# Abstract:
+#
+# SetMem32 function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# VOID *
+# EFIAPI
+# InternalMemSetMem32 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT32 Value
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
+ASM_PFX(InternalMemSetMem32):
+ movd %r8, %mm0 # mm0 <- Value
+ movq %rcx, %rax # rax <- Buffer
+ xchgq %rdx, %rcx # rcx <- Count rdx <- Buffer
+ shrq $1, % rcx # rcx <- # of qwords to set
+ jz L_SetDwords
+ .byte 0x0f, 0x70, 0x0C0, 0x44
+L0:
+ movntq %mm0, (%rdx)
+ leaq 8(%rdx), %rdx # use "lea" to avoid flag changes
+ loop L0
+ mfence
+L_SetDwords:
+ jnc L1
+ movd %mm0, (%rdx)
+L1:
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm
new file mode 100644
index 0000000000..a0bdd89bed
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem32.asm
+;
+; Abstract:
+;
+; SetMem32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem32 PROC
+ DB 49h, 0fh, 6eh, 0c0h ; movd mm0, r8 (Value)
+ mov rax, rcx ; rax <- Buffer
+ xchg rcx, rdx ; rcx <- Count rdx <- Buffer
+ shr rcx, 1 ; rcx <- # of qwords to set
+ jz @SetDwords
+ DB 0fh, 70h, 0C0h, 44h ; pshufw mm0, mm0, 44h
+@@:
+ DB 0fh, 0e7h, 02h ; movntq [rdx], mm0
+ lea rdx, [rdx + 8] ; use "lea" to avoid flag changes
+ loop @B
+ mfence
+@SetDwords:
+ jnc @F
+ DB 0fh, 7eh, 02h ; movd [rdx], mm0
+@@:
+ ret
+InternalMemSetMem32 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.S
new file mode 100644
index 0000000000..a4c7d8cb62
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.S
@@ -0,0 +1,47 @@
+#
+# ConvertAsm.py: Automatically generated from SetMem64.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SetMem64.S
+#
+# Abstract:
+#
+# SetMem64 function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem64 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT64 Value
+# )
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
+ASM_PFX(InternalMemSetMem64):
+ movd %r8, %mm0 #Value
+ movq %rcx, %rax #rax <- Buffer
+ xchg %rdx, %rcx #rcx <- Count
+L0:
+ movntq %mm0, (%rdx)
+ addq $8, %rdx
+ loop L0
+ mfence
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm
new file mode 100644
index 0000000000..f26177fa11
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm
@@ -0,0 +1,46 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem64.asm
+;
+; Abstract:
+;
+; SetMem64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem64 PROC
+ DB 49h, 0fh, 6eh, 0c0h ; movd mm0, r8 (Value)
+ mov rax, rcx ; rax <- Buffer
+ xchg rcx, rdx ; rcx <- Count
+@@:
+ DB 0fh, 0e7h, 02h ; movntq [rdx], mm0
+ add rdx, 8
+ loop @B
+ mfence
+ ret
+InternalMemSetMem64 ENDP
+
+ END
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.S b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.S
new file mode 100644
index 0000000000..79f0b3d501
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.S
@@ -0,0 +1,57 @@
+#
+# ConvertAsm.py: Automatically generated from ZeroMem.asm
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+# 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
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ZeroMem.S
+#
+# Abstract:
+#
+# ZeroMem function
+#
+# Notes:
+#
+#------------------------------------------------------------------------------
+
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemZeroMem (
+# IN VOID *Buffer,
+# IN UINTN Count
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
+ASM_PFX(InternalMemZeroMem):
+ pushq %rdi
+ movq %rcx, %rdi
+ movq %rdx, %rcx
+ movq %rdi, %r8
+ andq $7, %rdx
+ shrq $3, %rcx
+ jz L_ZeroBytes
+ pxor %mm0, %mm0
+L0:
+ movntq %mm0, (%rdi)
+ addq $8, %rdi
+ loop L0
+ mfence
+L_ZeroBytes:
+ xorl %eax, %eax
+ movl %edx, %ecx
+ rep stosb
+ movq %r8, %rax
+ popq %rdi
+ ret
+
diff --git a/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm
new file mode 100644
index 0000000000..0fcf50ce8b
--- /dev/null
+++ b/Core/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm
@@ -0,0 +1,54 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; 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
+; http://opensource.org/licenses/bsd-license.php.
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ZeroMem.asm
+;
+; Abstract:
+;
+; ZeroMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMemZeroMem PROC USES rdi
+ mov rdi, rcx
+ mov rcx, rdx
+ mov r8, rdi
+ and edx, 7
+ shr rcx, 3
+ jz @ZeroBytes
+ DB 0fh, 0efh, 0c0h ; pxor mm0, mm0
+@@:
+ DB 0fh, 0e7h, 7 ; movntq [rdi], mm0
+ add rdi, 8
+ loop @B
+ DB 0fh, 0aeh, 0f0h ; mfence
+@ZeroBytes:
+ xor eax, eax
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+ ret
+InternalMemZeroMem ENDP
+
+ END