summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-06-28 07:00:39 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2007-06-28 07:00:39 +0000
commit3eb9473ea9a949badfe06ae61d2d3fcfa53651c7 (patch)
treee9d8c368dbb1e58794b2c00acefe4bbad270f8c4 /EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64
parent30d4a0c7ec19938196b1308006b990e0945150da (diff)
downloadedk2-platforms-3eb9473ea9a949badfe06ae61d2d3fcfa53651c7.tar.xz
Add in the 1st version of ECP.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2832 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64')
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm74
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm80
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm60
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm67
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm53
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm60
6 files changed, 394 insertions, 0 deletions
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm
new file mode 100644
index 0000000000..9d1e04b2ba
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMem.asm
@@ -0,0 +1,74 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, 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
+; 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
+; EfiCommonLibCopyMem (
+; OUT VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibCopyMem PROC USES rsi rdi
+ cmp rdx, rcx ; if Source == Destination, do nothing
+ je @CopyMemDone
+ cmp r8, 0 ; if Count == 0, do nothing
+ je @CopyMemDone
+ 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 48h, 0fh, 7eh, 07h ; movd [rdi], mm0
+ add rsi, 8
+ add rdi, 8
+ loop @B
+ 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
+@CopyMemDone:
+ ret
+EfiCommonLibCopyMem ENDP
+
+ END
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm
new file mode 100644
index 0000000000..9e60e94951
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiCopyMemSSE2.asm
@@ -0,0 +1,80 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, 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
+; 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
+; EfiCommonLibCopyMem (
+; OUT VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibCopyMem PROC USES rsi rdi
+ cmp rdx, rcx ; if Source == Destination, do nothing
+ je @CopyMemDone
+ cmp r8, 0 ; if Count == 0, do nothing
+ je @CopyMemDone
+ 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 ; Copy forward if Source > Destination
+ cmp r9, rdi ; Overlapped?
+ jae @CopyBackward ; Copy backward if overlapped
+@@:
+ xor rcx, rcx
+ sub rcx, rdi ; rcx <- -rdi
+ and rcx, 15 ; rcx + rsi should be 16 bytes aligned
+ jz @F ; skip if rcx == 0
+ cmp rcx, r8
+ cmova rcx, r8
+ sub r8, rcx
+ rep movsb
+@@:
+ mov rcx, r8
+ and r8, 15
+ shr rcx, 4 ; rcx <- # of DQwords to copy
+ jz @CopyBytes
+@@:
+ movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned
+ movdqa [rdi], xmm0 ; rdi should be 16-byte aligned
+ add rsi, 16
+ add rdi, 16
+ loop @B
+ jmp @CopyBytes ; copy remaining bytes
+@CopyBackward:
+ mov rsi, r9 ; rsi <- Last byte of Source
+ lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination
+ std
+@CopyBytes:
+ mov rcx, r8
+ rep movsb
+ cld
+@CopyMemDone:
+ ret
+EfiCommonLibCopyMem ENDP
+
+ END
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm
new file mode 100644
index 0000000000..7568a520fd
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMem.asm
@@ -0,0 +1,60 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, 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
+; 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
+; EfiCommonLibSetMem (
+; OUT VOID *Buffer,
+; IN UINTN Size,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibSetMem PROC USES rdi
+ cmp rdx, 0 ; if Size == 0, do nothing
+ je @SetDone
+ 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 48h, 0fh, 7eh, 07h ; movd [rdi], mm0
+ add rdi, 8
+ loop @B
+@SetBytes:
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+@SetDone:
+ ret
+EfiCommonLibSetMem ENDP
+
+ END
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm
new file mode 100644
index 0000000000..8667d7e142
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiSetMemSSE2.asm
@@ -0,0 +1,67 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, 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
+; 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
+; EfiCommonLibSetMem (
+; OUT VOID *Buffer,
+; IN UINTN Size,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibSetMem PROC USES rdi
+ cmp rdx, 0 ; if Size == 0, do nothing
+ je @SetDone
+ mov rdi, rcx ; rdi <- Buffer
+ mov al, r8b ; al <- Value
+ xor rcx, rcx
+ sub rcx, rdi
+ and rcx, 15 ; rcx + rdi aligns on 16-byte boundary
+ jz @F
+ cmp rcx, rdx
+ cmova rcx, rdx
+ sub rdx, rcx
+ rep stosb
+@@:
+ mov rcx, rdx
+ and rdx, 15
+ shr rcx, 4
+ jz @SetBytes
+ mov ah, al ; ax <- Value repeats twice
+ 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
+@@:
+ movdqa [rdi], xmm0 ; rdi should be 16-byte aligned
+ add rdi, 16
+ loop @B
+@SetBytes:
+ mov ecx, edx ; high 32 bits of rcx are always zero
+ rep stosb
+@SetDone:
+ ret
+EfiCommonLibSetMem ENDP
+
+ END
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm
new file mode 100644
index 0000000000..5f2c077673
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMem.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, 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
+; 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 *
+; EfiCommonLibZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Size
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibZeroMem 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 48h, 0fh, 7eh, 07h ; movd [rdi], mm0
+ add rdi, 8
+ loop @B
+@ZeroBytes:
+ xor eax, eax
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+ ret
+EfiCommonLibZeroMem ENDP
+
+ END
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm
new file mode 100644
index 0000000000..58cf76e1af
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/x64/EfiZeroMemSSE2.asm
@@ -0,0 +1,60 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, 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
+; 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
+; EfiCommonLibZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Size
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibZeroMem PROC USES rdi
+ mov rdi, rcx
+ xor rcx, rcx
+ xor eax, eax
+ sub rcx, rdi
+ and rcx, 15
+ jz @F
+ cmp rcx, rdx
+ cmova rcx, rdx
+ sub rdx, rcx
+ rep stosb
+@@:
+ mov rcx, rdx
+ and edx, 15
+ shr rcx, 4
+ jz @ZeroBytes
+ pxor xmm0, xmm0
+@@:
+ movdqa [rdi], xmm0 ; rdi should be 16-byte aligned
+ add rdi, 16
+ loop @B
+@ZeroBytes:
+ mov ecx, edx
+ rep stosb
+ ret
+EfiCommonLibZeroMem ENDP
+
+ END