aboutsummaryrefslogtreecommitdiffstats
path: root/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64
diff options
context:
space:
mode:
Diffstat (limited to 'roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64')
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.nasm52
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.nasm68
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/IsZeroBuffer.nasm49
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.nasm49
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.nasm49
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.nasm49
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.nasm49
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.nasm54
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.nasm53
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.nasm47
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.nasm40
-rw-r--r--roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.nasm50
12 files changed, 609 insertions, 0 deletions
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.nasm
new file mode 100644
index 000000000..5514ab663
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.nasm
@@ -0,0 +1,52 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; CompareMem.Asm
+;
+; Abstract:
+;
+; CompareMem function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemCompareMem)
+ASM_PFX(InternalMemCompareMem):
+ push rsi
+ push rdi
+ mov rsi, rcx
+ mov rdi, rdx
+ mov rcx, r8
+ repe cmpsb
+ movzx rax, byte [rsi - 1]
+ movzx rdx, byte [rdi - 1]
+ sub rax, rdx
+ pop rdi
+ pop rsi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.nasm
new file mode 100644
index 000000000..5769c00bf
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.nasm
@@ -0,0 +1,68 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; CopyMem.nasm
+;
+; Abstract:
+;
+; CopyMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemCopyMem (
+; OUT VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+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 <- End of Source
+ cmp rsi, rdi
+ mov rax, rdi ; rax <- Destination as return value
+ jae .0
+ cmp r9, rdi
+ jae @CopyBackward ; Copy backward if overlapped
+.0:
+ mov rcx, r8
+ and r8, 7
+ shr rcx, 3 ; rcx <- # of Qwords to copy
+ jz @CopyBytes
+ DB 0x49, 0xf, 0x7e, 0xc2 ; movd r10, mm0 (Save mm0 in r10)
+.1:
+ DB 0xf, 0x6f, 0x6 ; movd mm0, [rsi]
+ DB 0xf, 0xe7, 0x7 ; movntq [rdi], mm0
+ add rsi, 8
+ add rdi, 8
+ loop .1
+ mfence
+ DB 0x49, 0xf, 0x6e, 0xc2 ; 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
+ pop rdi
+ pop rsi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/IsZeroBuffer.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/IsZeroBuffer.nasm
new file mode 100644
index 000000000..a6e1d817f
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/IsZeroBuffer.nasm
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; IsZeroBuffer.nasm
+;
+; Abstract:
+;
+; IsZeroBuffer function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; BOOLEAN
+; EFIAPI
+; InternalMemIsZeroBuffer (
+; IN CONST VOID *Buffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemIsZeroBuffer)
+ASM_PFX(InternalMemIsZeroBuffer):
+ push rdi
+ mov rdi, rcx ; rdi <- Buffer
+ mov rcx, rdx ; rcx <- Length
+ shr rcx, 3 ; rcx <- number of qwords
+ and rdx, 7 ; rdx <- number of trailing bytes
+ xor rax, rax ; rax <- 0, also set ZF
+ repe scasq
+ jnz @ReturnFalse ; ZF=0 means non-zero element found
+ mov rcx, rdx
+ repe scasb
+ jnz @ReturnFalse
+ pop rdi
+ mov rax, 1 ; return TRUE
+ ret
+@ReturnFalse:
+ pop rdi
+ xor rax, rax
+ ret ; return FALSE
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.nasm
new file mode 100644
index 000000000..eb385a4a2
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.nasm
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; ScanMem16.Asm
+;
+; Abstract:
+;
+; ScanMem16 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemScanMem16)
+ASM_PFX(InternalMemScanMem16):
+ push rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasw
+ lea rax, [rdi - 2]
+ cmovnz rax, rcx
+ pop rdi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.nasm
new file mode 100644
index 000000000..6fccdf2d1
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.nasm
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; ScanMem32.Asm
+;
+; Abstract:
+;
+; ScanMem32 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
+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
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.nasm
new file mode 100644
index 000000000..6659aef44
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.nasm
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; ScanMem64.Asm
+;
+; Abstract:
+;
+; ScanMem64 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemScanMem64)
+ASM_PFX(InternalMemScanMem64):
+ push rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasq
+ lea rax, [rdi - 8]
+ cmovnz rax, rcx
+ pop rdi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.nasm
new file mode 100644
index 000000000..16fd931c0
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.nasm
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; ScanMem8.Asm
+;
+; Abstract:
+;
+; ScanMem8 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances contain the same copy of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+; BaseMemoryLibOptDxe
+; BaseMemoryLibOptPei
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemScanMem8)
+ASM_PFX(InternalMemScanMem8):
+ push 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
+ pop rdi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.nasm
new file mode 100644
index 000000000..450113ba8
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.nasm
@@ -0,0 +1,54 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; SetMem.nasm
+;
+; Abstract:
+;
+; SetMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem (
+; OUT VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemSetMem)
+ASM_PFX(InternalMemSetMem):
+ push rdi
+ mov rax, r8
+ mov ah, al
+ DB 0x48, 0xf, 0x6e, 0xc0 ; movd mm0, rax
+ mov r8, rcx
+ mov rdi, r8 ; rdi <- Buffer
+ mov rcx, rdx
+ and edx, 7
+ shr rcx, 3
+ jz @SetBytes
+ DB 0xf, 0x70, 0xC0, 0x0 ; pshufw mm0, mm0, 0h
+.0:
+ DB 0xf, 0xe7, 0x7 ; movntq [rdi], mm0
+ add rdi, 8
+ loop .0
+ mfence
+@SetBytes:
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+ pop rdi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.nasm
new file mode 100644
index 000000000..4e1f4be2b
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.nasm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; SetMem16.nasm
+;
+; Abstract:
+;
+; SetMem16 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem16 (
+; OUT VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemSetMem16)
+ASM_PFX(InternalMemSetMem16):
+ push rdi
+ mov rax, r8
+ DB 0x48, 0xf, 0x6e, 0xc0 ; movd mm0, rax
+ mov r8, rcx
+ mov rdi, r8
+ mov rcx, rdx
+ and edx, 3
+ shr rcx, 2
+ jz @SetWords
+ DB 0xf, 0x70, 0xC0, 0x0 ; pshufw mm0, mm0, 0h
+.0:
+ DB 0xf, 0xe7, 0x7 ; movntq [rdi], mm0
+ add rdi, 8
+ loop .0
+ mfence
+@SetWords:
+ mov ecx, edx
+ rep stosw
+ mov rax, r8
+ pop rdi
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.nasm
new file mode 100644
index 000000000..b3a738589
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.nasm
@@ -0,0 +1,47 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; SetMem32.nasm
+;
+; Abstract:
+;
+; SetMem32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; )
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemSetMem32)
+ASM_PFX(InternalMemSetMem32):
+ DB 0x49, 0xf, 0x6e, 0xc0 ; 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 0xf, 0x70, 0xC0, 0x44 ; pshufw mm0, mm0, 44h
+.0:
+ DB 0xf, 0xe7, 0x2 ; movntq [rdx], mm0
+ lea rdx, [rdx + 8] ; use "lea" to avoid flag changes
+ loop .0
+ mfence
+@SetDwords:
+ jnc .1
+ DB 0xf, 0x7e, 0x2 ; movd [rdx], mm0
+.1:
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.nasm
new file mode 100644
index 000000000..f517e1d23
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.nasm
@@ -0,0 +1,40 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; SetMem64.nasm
+;
+; Abstract:
+;
+; SetMem64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemSetMem64)
+ASM_PFX(InternalMemSetMem64):
+ DB 0x49, 0xf, 0x6e, 0xc0 ; movd mm0, r8 (Value)
+ mov rax, rcx ; rax <- Buffer
+ xchg rcx, rdx ; rcx <- Count
+.0:
+ DB 0xf, 0xe7, 0x2 ; movntq [rdx], mm0
+ add rdx, 8
+ loop .0
+ mfence
+ ret
+
diff --git a/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.nasm b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.nasm
new file mode 100644
index 000000000..2a85f15b5
--- /dev/null
+++ b/roms/edk2/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.nasm
@@ -0,0 +1,50 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Module Name:
+;
+; ZeroMem.nasm
+;
+; Abstract:
+;
+; ZeroMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ DEFAULT REL
+ SECTION .text
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+global ASM_PFX(InternalMemZeroMem)
+ASM_PFX(InternalMemZeroMem):
+ push rdi
+ mov rdi, rcx
+ mov rcx, rdx
+ mov r8, rdi
+ and edx, 7
+ shr rcx, 3
+ jz @ZeroBytes
+ DB 0xf, 0xef, 0xc0 ; pxor mm0, mm0
+.0:
+ DB 0xf, 0xe7, 7 ; movntq [rdi], mm0
+ add rdi, 8
+ loop .0
+ DB 0xf, 0xae, 0xf0 ; mfence
+@ZeroBytes:
+ xor eax, eax
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+ pop rdi
+ ret
+