From e2c05af969d26c45e082449d1cbb5002f04e0fe1 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Sat, 27 Sep 2008 05:28:23 +0000 Subject: Renamed remotely git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6017 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/EfiCommonLib/X64/EfiCopyMem.asm | 74 ++++++++++++++++++++ .../Library/EfiCommonLib/X64/EfiCopyMemRep1.S | 66 ++++++++++++++++++ .../Library/EfiCommonLib/X64/EfiCopyMemRep1.asm | 58 ++++++++++++++++ .../Library/EfiCommonLib/X64/EfiCopyMemRep4.asm | 65 ++++++++++++++++++ .../Library/EfiCommonLib/X64/EfiCopyMemRep8.asm | 65 ++++++++++++++++++ .../Library/EfiCommonLib/X64/EfiCopyMemSSE2.asm | 80 ++++++++++++++++++++++ .../Library/EfiCommonLib/X64/EfiSetMem.asm | 60 ++++++++++++++++ .../Library/EfiCommonLib/X64/EfiSetMemRep1.asm | 46 +++++++++++++ .../Library/EfiCommonLib/X64/EfiSetMemRep4.S | 54 +++++++++++++++ .../Library/EfiCommonLib/X64/EfiSetMemRep4.asm | 53 ++++++++++++++ .../Library/EfiCommonLib/X64/EfiSetMemRep8.asm | 58 ++++++++++++++++ .../Library/EfiCommonLib/X64/EfiSetMemSSE2.asm | 67 ++++++++++++++++++ .../Library/EfiCommonLib/X64/EfiZeroMem.asm | 53 ++++++++++++++ .../Library/EfiCommonLib/X64/EfiZeroMemRep1.asm | 42 ++++++++++++ .../Library/EfiCommonLib/X64/EfiZeroMemRep4.S | 46 +++++++++++++ .../Library/EfiCommonLib/X64/EfiZeroMemRep4.asm | 45 ++++++++++++ .../Library/EfiCommonLib/X64/EfiZeroMemRep8.asm | 45 ++++++++++++ .../Library/EfiCommonLib/X64/EfiZeroMemSSE2.asm | 60 ++++++++++++++++ 18 files changed, 1037 insertions(+) create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMem.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.S create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep8.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMem.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.S create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep8.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemSSE2.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMem.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep1.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.S create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep8.asm create mode 100644 EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemSSE2.asm (limited to 'EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64') 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/EfiCopyMemRep1.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.S new file mode 100644 index 0000000000..79455cfb79 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.S @@ -0,0 +1,66 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2008, 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: +# +# EfiCopyMemRep1.S +# +# Abstract: +# +# CopyMem function +# +# Notes: +# +#------------------------------------------------------------------------------ +#include + + .code: + +.global ASM_PFX(EfiCommonLibCopyMem) + +#------------------------------------------------------------------------------ +# VOID +# EfiCommonLibCopyMem ( +# OUT VOID *Destination, +# IN VOID *Source, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ +ASM_PFX(EfiCommonLibCopyMem): + push %rsi + push %rdi + cmp %rcx,%rdx + je CopyMemDone + cmp $0x0,%r8 + je CopyMemDone + mov %rdx,%rsi + mov %rcx,%rdi + lea -1(%r8,%rsi,1),%r9 + cmp %rdi,%rsi + jae CopyBytes + cmp %rdi,%r9 + jb CopyBytes + mov %r9,%rsi + lea -1(%r8,%rdi,1),%rdi + std + +CopyBytes: + mov %r8,%rcx + rep movsb %ds:(%rsi),%es:(%rdi) + cld + +CopyMemDone: + pop %rdi + pop %rsi + retq + + + diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.asm new file mode 100644 index 0000000000..b96d861477 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep1.asm @@ -0,0 +1,58 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiCopyMemRep1.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 + jae @CopyBytes + cmp r9, rdi + jb @CopyBytes ; Copy backward if overlapped + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; esi <- 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/EfiCopyMemRep4.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep4.asm new file mode 100644 index 0000000000..9cd3961d37 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep4.asm @@ -0,0 +1,65 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiCopyMemRep4.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 + jae @F + cmp r9, rdi + jae @CopyBackward ; Copy backward if overlapped +@@: + mov rcx, r8 + and r8, 3 + shr rcx, 2 + rep movsd ; Copy as many Dwords as possible + jmp @CopyBytes +@CopyBackward: + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; esi <- 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/EfiCopyMemRep8.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep8.asm new file mode 100644 index 0000000000..1494b9feb9 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMemRep8.asm @@ -0,0 +1,65 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiCopyMemRep8.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 + jae @F + cmp r9, rdi + jae @CopyBackward ; Copy backward if overlapped +@@: + mov rcx, r8 + and r8, 7 + shr rcx, 3 + rep movsq ; Copy as many Qwords as possible + jmp @CopyBytes +@CopyBackward: + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; esi <- 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/EfiSetMemRep1.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep1.asm new file mode 100644 index 0000000000..ef2ab8cb2f --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep1.asm @@ -0,0 +1,46 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiSetMemRep1.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 rax, r8 + mov rdi, rcx + mov rcx, rdx + rep stosb +@SetDone: + ret +EfiCommonLibSetMem ENDP + + END + diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.S new file mode 100644 index 0000000000..a9eb76ae67 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.S @@ -0,0 +1,54 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2008, 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: +# +# EfiSetMemRep4.S +# +# Abstract: +# +# SetMem function +# +# Notes: +# +#------------------------------------------------------------------------------ +#include + + .code: + +.global ASM_PFX(EfiCommonLibCopyMem) + +#------------------------------------------------------------------------------ +# VOID +# EfiCommonLibSetMem ( +# OUT VOID *Buffer, +# IN UINTN Size, +# IN UINT8 Value +# ); +#------------------------------------------------------------------------------ +ASM_PFX(EfiCommonLibSetMem): + push %rdi + cmp $0x0,%rdx + je SetDone + mov %rcx,%rdi + mov %r8b,%al + mov %al,%ah + shrd $0x10,%eax,%ecx + shld $0x10,%ecx,%eax + mov %rdx,%rcx + shr $0x2,%rcx + rep stos %eax,%es:(%rdi) + mov %rdx,%rcx + and $0x3,%rcx + rep stos %al,%es:(%rdi) +SetDone: + pop %rdi + retq diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.asm new file mode 100644 index 0000000000..8e3e7e5619 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep4.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: +; +; EfiSetMemRep4.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 + mov al, r8b + mov ah, al + shrd ecx, eax, 16 + shld eax, ecx, 16 + mov rcx, rdx + shr rcx, 2 + rep stosd + mov rcx, rdx + and rcx, 3 + rep stosb +@SetDone: + ret +EfiCommonLibSetMem ENDP + + END + diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep8.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep8.asm new file mode 100644 index 0000000000..09a76b1834 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiSetMemRep8.asm @@ -0,0 +1,58 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiSetMemRep8.asm +; +; Abstract: +; +; SetMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibSetMem ( +; OUT VOID *Buffer, +; IN UINTN Size, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ +EfiCommonLibSetMem PROC USES rdi rbx + cmp rdx, 0 ; if Size == 0, do nothing + je @SetDone + mov rax, r8 + mov bl, al + mov bh, bl + mov ax, bx + shl rax, 10h + mov ax, bx + mov ebx, eax + shl rax, 20h + mov eax, ebx + mov rdi, rcx + mov rcx, rdx + shr rcx, 3 + rep stosq + mov rcx, rdx + and rcx, 7 + rep stosb +@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/EfiZeroMemRep1.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep1.asm new file mode 100644 index 0000000000..6b66165ee2 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep1.asm @@ -0,0 +1,42 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiZeroMemRep1.asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibZeroMem ( +; IN VOID *Buffer, +; IN UINTN Size +; ); +;------------------------------------------------------------------------------ +EfiCommonLibZeroMem PROC USES rdi + xor rax, rax + mov rdi, rcx + mov rcx, rdx + rep stosb + ret +EfiCommonLibZeroMem ENDP + + END + diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.S new file mode 100644 index 0000000000..11b9b45ab7 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.S @@ -0,0 +1,46 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2008, 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: +# +# EfiZeroMemRep4.S +# +# Abstract: +# +# ZeroMem function +# +# Notes: +# +#------------------------------------------------------------------------------ +#include + + .code: + +.global ASM_PFX(EfiCommonLibZeroMem) +#------------------------------------------------------------------------------ +# VOID +# EfiCommonLibZeroMem ( +# IN VOID *Buffer, +# IN UINTN Size +# ); +#------------------------------------------------------------------------------ +ASM_PFX(EfiCommonLibZeroMem): + push %rdi + xor %rax,%rax + mov %rcx,%rdi + mov %rdx,%rcx + shr $0x2,%rcx + and $0x3,%rdx + rep stos %eax,%es:(%rdi) + mov %rdx,%rcx + rep stos %al,%es:(%rdi) + pop %rdi + retq \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.asm new file mode 100644 index 0000000000..7df6eee6a0 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep4.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiZeroMemRep4.asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibZeroMem ( +; IN VOID *Buffer, +; IN UINTN Size +; ); +;------------------------------------------------------------------------------ +EfiCommonLibZeroMem PROC USES rdi + xor rax, rax + mov rdi, rcx + mov rcx, rdx + shr rcx, 2 + and rdx, 3 + rep stosd + mov rcx, rdx + rep stosb + ret +EfiCommonLibZeroMem ENDP + + END \ No newline at end of file diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep8.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep8.asm new file mode 100644 index 0000000000..a93a702789 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiZeroMemRep8.asm @@ -0,0 +1,45 @@ +;------------------------------------------------------------------------------ +; +; 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: +; +; EfiZeroMemRep8.asm +; +; Abstract: +; +; ZeroMem function +; +; Notes: +; +;------------------------------------------------------------------------------ + + .code + +;------------------------------------------------------------------------------ +; VOID +; EfiCommonLibZeroMem ( +; IN VOID *Buffer, +; IN UINTN Size +; ); +;------------------------------------------------------------------------------ +EfiCommonLibZeroMem PROC USES rdi + xor rax, rax + mov rdi, rcx + mov rcx, rdx + shr rcx, 3 + and rdx, 7 + rep stosq + mov rcx, rdx + rep stosb + ret +EfiCommonLibZeroMem ENDP + + END \ No newline at end of file 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 -- cgit v1.2.3