--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; CompareMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+; CompareMem function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances contain the same copy of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+; BaseMemoryLibOptDxe\r
+; BaseMemoryLibOptPei\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; INTN\r
+; EFIAPI\r
+; InternalMemCompareMem (\r
+; IN CONST VOID *DestinationBuffer,\r
+; IN CONST VOID *SourceBuffer,\r
+; IN UINTN Length\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemCompareMem PROC USES rsi rdi\r
+ mov rsi, rcx\r
+ mov rdi, rdx\r
+ mov rcx, r8\r
+ repe cmpsb\r
+ movzx rax, byte ptr [rsi - 1]\r
+ movzx rdx, byte ptr [rdi - 1]\r
+ sub rax, rdx\r
+ ret\r
+InternalMemCompareMem ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; CopyMem.asm\r
+;\r
+; Abstract:\r
+;\r
+; CopyMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; EFIAPI\r
+; InternalMemCopyMem (\r
+; IN VOID *Destination,\r
+; IN VOID *Source,\r
+; IN UINTN Count\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemCopyMem PROC USES rsi rdi\r
+ mov rsi, rdx ; rsi <- Source\r
+ mov rdi, rcx ; rdi <- Destination\r
+ lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source\r
+ cmp rsi, rdi\r
+ mov rax, rdi ; rax <- Destination as return value\r
+ jae @F ; Copy forward if Source > Destination\r
+ cmp r9, rdi ; Overlapped?\r
+ jae @CopyBackward ; Copy backward if overlapped\r
+@@:\r
+ xor rcx, rcx\r
+ sub rcx, rdi ; rcx <- -rdi\r
+ and rcx, 15 ; rcx + rsi should be 16 bytes aligned\r
+ jz @F ; skip if rcx == 0\r
+ cmp rcx, r8\r
+ cmova rcx, r8\r
+ sub r8, rcx\r
+ rep movsb\r
+@@:\r
+ mov rcx, r8\r
+ and r8, 15\r
+ shr rcx, 4 ; rcx <- # of DQwords to copy\r
+ jz @CopyBytes\r
+ movdqa [rsp + 18h], xmm0 ; save xmm0 on stack\r
+@@:\r
+ movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned\r
+ movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
+ add rsi, 16\r
+ add rdi, 16\r
+ loop @B\r
+ mfence\r
+ movdqa xmm0, [rsp + 18h] ; restore xmm0\r
+ jmp @CopyBytes ; copy remaining bytes\r
+@CopyBackward:\r
+ mov rsi, r9 ; rsi <- Last byte of Source\r
+ lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination\r
+ std\r
+@CopyBytes:\r
+ mov rcx, r8\r
+ rep movsb\r
+ cld\r
+ ret\r
+InternalMemCopyMem ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem16.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem16 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances contain the same copy of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+; BaseMemoryLibOptDxe\r
+; BaseMemoryLibOptPei\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; CONST VOID *\r
+; EFIAPI\r
+; InternalMemScanMem16 (\r
+; IN CONST VOID *Buffer,\r
+; IN UINTN Length,\r
+; IN UINT16 Value\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemScanMem16 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ mov rcx, rdx\r
+ repne scasw\r
+ lea rax, [rdi - 2]\r
+ cmovnz rax, rcx\r
+ ret\r
+InternalMemScanMem16 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem32.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem32 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances contain the same copy of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+; BaseMemoryLibOptDxe\r
+; BaseMemoryLibOptPei\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; CONST VOID *\r
+; EFIAPI\r
+; InternalMemScanMem32 (\r
+; IN CONST VOID *Buffer,\r
+; IN UINTN Length,\r
+; IN UINT32 Value\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemScanMem32 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ mov rcx, rdx\r
+ repne scasd\r
+ lea rax, [rdi - 4]\r
+ cmovnz rax, rcx\r
+ ret\r
+InternalMemScanMem32 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem64.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem64 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances contain the same copy of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+; BaseMemoryLibOptDxe\r
+; BaseMemoryLibOptPei\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; CONST VOID *\r
+; EFIAPI\r
+; InternalMemScanMem64 (\r
+; IN CONST VOID *Buffer,\r
+; IN UINTN Length,\r
+; IN UINT64 Value\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemScanMem64 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rax, r8\r
+ mov rcx, rdx\r
+ repne scasq\r
+ lea rax, [rdi - 8]\r
+ cmovnz rax, rcx\r
+ ret\r
+InternalMemScanMem64 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ScanMem8.Asm\r
+;\r
+; Abstract:\r
+;\r
+; ScanMem8 function\r
+;\r
+; Notes:\r
+;\r
+; The following BaseMemoryLib instances contain the same copy of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+; BaseMemoryLibOptDxe\r
+; BaseMemoryLibOptPei\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; CONST VOID *\r
+; EFIAPI\r
+; InternalMemScanMem8 (\r
+; IN CONST VOID *Buffer,\r
+; IN UINTN Length,\r
+; IN UINT8 Value\r
+; );\r
+;------------------------------------------------------------------------------\r
+InternalMemScanMem8 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov rcx, rdx\r
+ mov rax, r8\r
+ repne scasb\r
+ lea rax, [rdi - 1]\r
+ cmovnz rax, rcx ; set rax to 0 if not found\r
+ ret\r
+InternalMemScanMem8 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem.asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT8 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem PROC USES rdi\r
+ mov rdi, rcx ; rdi <- Buffer\r
+ mov al, r8b ; al <- Value\r
+ mov r9, rdi ; r9 <- Buffer as return value\r
+ xor rcx, rcx\r
+ sub rcx, rdi\r
+ and rcx, 15 ; rcx + rdi aligns on 16-byte boundary\r
+ jz @F\r
+ cmp rcx, rdx\r
+ cmova rcx, rdx\r
+ sub rdx, rcx\r
+ rep stosb\r
+@@:\r
+ mov rcx, rdx\r
+ and rdx, 15\r
+ shr rcx, 4\r
+ jz @SetBytes\r
+ mov ah, al ; ax <- Value repeats twice\r
+ movdqa [rsp + 10h], xmm0 ; save xmm0\r
+ movd xmm0, eax ; xmm0[0..16] <- Value repeats twice\r
+ pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times\r
+ movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times\r
+@@:\r
+ movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
+ add rdi, 16\r
+ loop @B\r
+ mfence\r
+ movdqa xmm0, [rsp + 10h] ; restore xmm0\r
+@SetBytes:\r
+ mov ecx, edx ; high 32 bits of rcx are always zero\r
+ rep stosb\r
+ mov rax, r9 ; rax <- Return value\r
+ ret\r
+InternalMemSetMem ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem16.asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem16 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem16 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT16 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem16 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov r9, rdi\r
+ xor rcx, rcx\r
+ sub rcx, rdi\r
+ and rcx, 15\r
+ mov rax, r8\r
+ jz @F\r
+ shr rcx, 1\r
+ cmp rcx, rdx\r
+ cmova rcx, rdx\r
+ sub rdx, rcx\r
+ rep stosw\r
+@@:\r
+ mov rcx, rdx\r
+ and edx, 7\r
+ shr rcx, 3\r
+ jz @SetWords\r
+ movd xmm0, eax\r
+ pshuflw xmm0, xmm0, 0\r
+ movlhps xmm0, xmm0\r
+@@:\r
+ movntdq [rdi], xmm0\r
+ add rdi, 16\r
+ loop @B\r
+ mfence\r
+@SetWords:\r
+ mov ecx, edx\r
+ rep stosw\r
+ mov rax, r9\r
+ ret\r
+InternalMemSetMem16 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem32.asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem32 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem32 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT8 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem32 PROC USES rdi\r
+ mov rdi, rcx\r
+ mov r9, rdi\r
+ xor rcx, rcx\r
+ sub rcx, rdi\r
+ and rcx, 15\r
+ mov rax, r8\r
+ jz @F\r
+ shr rcx, 2\r
+ cmp rcx, rdx\r
+ cmova rcx, rdx\r
+ sub rdx, rcx\r
+ rep stosd\r
+@@:\r
+ mov rcx, rdx\r
+ and edx, 3\r
+ shr rcx, 2\r
+ jz @SetDwords\r
+ movd xmm0, eax\r
+ pshufd xmm0, xmm0, 0\r
+@@:\r
+ movntdq [rdi], xmm0\r
+ add rdi, 16\r
+ loop @B\r
+ mfence\r
+@SetDwords:\r
+ mov ecx, edx\r
+ rep stosd\r
+ mov rax, r9\r
+ ret\r
+InternalMemSetMem32 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; SetMem64.asm\r
+;\r
+; Abstract:\r
+;\r
+; SetMem64 function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemSetMem64 (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count,\r
+; IN UINT64 Value\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemSetMem64 PROC\r
+ mov rax, rcx ; rax <- Buffer\r
+ xchg rcx, rdx ; rcx <- Count & rdx <- Buffer\r
+ test dl, 8\r
+ movd xmm0, r8\r
+ jz @F\r
+ mov [rdx], r8\r
+ add rdx, 8\r
+ dec rcx\r
+@@:\r
+ shr rcx, 1\r
+ jz @SetQwords\r
+ movlhps xmm0, xmm0\r
+@@:\r
+ movntdq [rdx], xmm0\r
+ lea rdx, [rdx + 16]\r
+ loop @B\r
+ mfence\r
+@SetQwords:\r
+ jnc @F\r
+ mov [rdx], r8\r
+@@:\r
+ ret\r
+InternalMemSetMem64 ENDP\r
+\r
+ END\r
--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, Intel Corporation\r
+; All rights reserved. This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; ZeroMem.asm\r
+;\r
+; Abstract:\r
+;\r
+; ZeroMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID *\r
+; InternalMemZeroMem (\r
+; IN VOID *Buffer,\r
+; IN UINTN Count\r
+; )\r
+;------------------------------------------------------------------------------\r
+InternalMemZeroMem PROC USES rdi\r
+ mov rdi, rcx\r
+ xor rcx, rcx\r
+ xor eax, eax\r
+ sub rcx, rdi\r
+ and rcx, 15\r
+ mov r8, rdi\r
+ jz @F\r
+ cmp rcx, rdx\r
+ cmova rcx, rdx\r
+ sub rdx, rcx\r
+ rep stosb\r
+@@:\r
+ mov rcx, rdx\r
+ and edx, 15\r
+ shr rcx, 4\r
+ jz @ZeroBytes\r
+ pxor xmm0, xmm0\r
+@@:\r
+ movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
+ add rdi, 16\r
+ loop @B\r
+ mfence\r
+@ZeroBytes:\r
+ mov ecx, edx\r
+ rep stosb\r
+ mov rax, r8\r
+ ret\r
+InternalMemZeroMem ENDP\r
+\r
+ END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; CompareMem.Asm\r
-;\r
-; Abstract:\r
-;\r
-; CompareMem function\r
-;\r
-; Notes:\r
-;\r
-; The following BaseMemoryLib instances contain the same copy of this file:\r
-;\r
-; BaseMemoryLibRepStr\r
-; BaseMemoryLibMmx\r
-; BaseMemoryLibSse2\r
-; BaseMemoryLibOptDxe\r
-; BaseMemoryLibOptPei\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; INTN\r
-; EFIAPI\r
-; InternalMemCompareMem (\r
-; IN CONST VOID *DestinationBuffer,\r
-; IN CONST VOID *SourceBuffer,\r
-; IN UINTN Length\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalMemCompareMem PROC USES rsi rdi\r
- mov rsi, rcx\r
- mov rdi, rdx\r
- mov rcx, r8\r
- repe cmpsb\r
- movzx rax, byte ptr [rsi - 1]\r
- movzx rdx, byte ptr [rdi - 1]\r
- sub rax, rdx\r
- ret\r
-InternalMemCompareMem ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; CopyMem.asm\r
-;\r
-; Abstract:\r
-;\r
-; CopyMem function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID *\r
-; EFIAPI\r
-; InternalMemCopyMem (\r
-; IN VOID *Destination,\r
-; IN VOID *Source,\r
-; IN UINTN Count\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalMemCopyMem PROC USES rsi rdi\r
- mov rsi, rdx ; rsi <- Source\r
- mov rdi, rcx ; rdi <- Destination\r
- lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source\r
- cmp rsi, rdi\r
- mov rax, rdi ; rax <- Destination as return value\r
- jae @F ; Copy forward if Source > Destination\r
- cmp r9, rdi ; Overlapped?\r
- jae @CopyBackward ; Copy backward if overlapped\r
-@@:\r
- xor rcx, rcx\r
- sub rcx, rdi ; rcx <- -rdi\r
- and rcx, 15 ; rcx + rsi should be 16 bytes aligned\r
- jz @F ; skip if rcx == 0\r
- cmp rcx, r8\r
- cmova rcx, r8\r
- sub r8, rcx\r
- rep movsb\r
-@@:\r
- mov rcx, r8\r
- and r8, 15\r
- shr rcx, 4 ; rcx <- # of DQwords to copy\r
- jz @CopyBytes\r
- movdqa [rsp + 18h], xmm0 ; save xmm0 on stack\r
-@@:\r
- movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned\r
- movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
- add rsi, 16\r
- add rdi, 16\r
- loop @B\r
- mfence\r
- movdqa xmm0, [rsp + 18h] ; restore xmm0\r
- jmp @CopyBytes ; copy remaining bytes\r
-@CopyBackward:\r
- mov rsi, r9 ; rsi <- Last byte of Source\r
- lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination\r
- std\r
-@CopyBytes:\r
- mov rcx, r8\r
- rep movsb\r
- cld\r
- ret\r
-InternalMemCopyMem ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; ScanMem16.Asm\r
-;\r
-; Abstract:\r
-;\r
-; ScanMem16 function\r
-;\r
-; Notes:\r
-;\r
-; The following BaseMemoryLib instances contain the same copy of this file:\r
-;\r
-; BaseMemoryLibRepStr\r
-; BaseMemoryLibMmx\r
-; BaseMemoryLibSse2\r
-; BaseMemoryLibOptDxe\r
-; BaseMemoryLibOptPei\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; CONST VOID *\r
-; EFIAPI\r
-; InternalMemScanMem16 (\r
-; IN CONST VOID *Buffer,\r
-; IN UINTN Length,\r
-; IN UINT16 Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalMemScanMem16 PROC USES rdi\r
- mov rdi, rcx\r
- mov rax, r8\r
- mov rcx, rdx\r
- repne scasw\r
- lea rax, [rdi - 2]\r
- cmovnz rax, rcx\r
- ret\r
-InternalMemScanMem16 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; ScanMem32.Asm\r
-;\r
-; Abstract:\r
-;\r
-; ScanMem32 function\r
-;\r
-; Notes:\r
-;\r
-; The following BaseMemoryLib instances contain the same copy of this file:\r
-;\r
-; BaseMemoryLibRepStr\r
-; BaseMemoryLibMmx\r
-; BaseMemoryLibSse2\r
-; BaseMemoryLibOptDxe\r
-; BaseMemoryLibOptPei\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; CONST VOID *\r
-; EFIAPI\r
-; InternalMemScanMem32 (\r
-; IN CONST VOID *Buffer,\r
-; IN UINTN Length,\r
-; IN UINT32 Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalMemScanMem32 PROC USES rdi\r
- mov rdi, rcx\r
- mov rax, r8\r
- mov rcx, rdx\r
- repne scasd\r
- lea rax, [rdi - 4]\r
- cmovnz rax, rcx\r
- ret\r
-InternalMemScanMem32 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; ScanMem64.Asm\r
-;\r
-; Abstract:\r
-;\r
-; ScanMem64 function\r
-;\r
-; Notes:\r
-;\r
-; The following BaseMemoryLib instances contain the same copy of this file:\r
-;\r
-; BaseMemoryLibRepStr\r
-; BaseMemoryLibMmx\r
-; BaseMemoryLibSse2\r
-; BaseMemoryLibOptDxe\r
-; BaseMemoryLibOptPei\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; CONST VOID *\r
-; EFIAPI\r
-; InternalMemScanMem64 (\r
-; IN CONST VOID *Buffer,\r
-; IN UINTN Length,\r
-; IN UINT64 Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalMemScanMem64 PROC USES rdi\r
- mov rdi, rcx\r
- mov rax, r8\r
- mov rcx, rdx\r
- repne scasq\r
- lea rax, [rdi - 8]\r
- cmovnz rax, rcx\r
- ret\r
-InternalMemScanMem64 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; ScanMem8.Asm\r
-;\r
-; Abstract:\r
-;\r
-; ScanMem8 function\r
-;\r
-; Notes:\r
-;\r
-; The following BaseMemoryLib instances contain the same copy of this file:\r
-;\r
-; BaseMemoryLibRepStr\r
-; BaseMemoryLibMmx\r
-; BaseMemoryLibSse2\r
-; BaseMemoryLibOptDxe\r
-; BaseMemoryLibOptPei\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; CONST VOID *\r
-; EFIAPI\r
-; InternalMemScanMem8 (\r
-; IN CONST VOID *Buffer,\r
-; IN UINTN Length,\r
-; IN UINT8 Value\r
-; );\r
-;------------------------------------------------------------------------------\r
-InternalMemScanMem8 PROC USES rdi\r
- mov rdi, rcx\r
- mov rcx, rdx\r
- mov rax, r8\r
- repne scasb\r
- lea rax, [rdi - 1]\r
- cmovnz rax, rcx ; set rax to 0 if not found\r
- ret\r
-InternalMemScanMem8 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; SetMem.asm\r
-;\r
-; Abstract:\r
-;\r
-; SetMem function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID *\r
-; InternalMemSetMem (\r
-; IN VOID *Buffer,\r
-; IN UINTN Count,\r
-; IN UINT8 Value\r
-; )\r
-;------------------------------------------------------------------------------\r
-InternalMemSetMem PROC USES rdi\r
- mov rdi, rcx ; rdi <- Buffer\r
- mov al, r8b ; al <- Value\r
- mov r9, rdi ; r9 <- Buffer as return value\r
- xor rcx, rcx\r
- sub rcx, rdi\r
- and rcx, 15 ; rcx + rdi aligns on 16-byte boundary\r
- jz @F\r
- cmp rcx, rdx\r
- cmova rcx, rdx\r
- sub rdx, rcx\r
- rep stosb\r
-@@:\r
- mov rcx, rdx\r
- and rdx, 15\r
- shr rcx, 4\r
- jz @SetBytes\r
- mov ah, al ; ax <- Value repeats twice\r
- movdqa [rsp + 10h], xmm0 ; save xmm0\r
- movd xmm0, eax ; xmm0[0..16] <- Value repeats twice\r
- pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times\r
- movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times\r
-@@:\r
- movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
- add rdi, 16\r
- loop @B\r
- mfence\r
- movdqa xmm0, [rsp + 10h] ; restore xmm0\r
-@SetBytes:\r
- mov ecx, edx ; high 32 bits of rcx are always zero\r
- rep stosb\r
- mov rax, r9 ; rax <- Return value\r
- ret\r
-InternalMemSetMem ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; SetMem16.asm\r
-;\r
-; Abstract:\r
-;\r
-; SetMem16 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID *\r
-; InternalMemSetMem16 (\r
-; IN VOID *Buffer,\r
-; IN UINTN Count,\r
-; IN UINT16 Value\r
-; )\r
-;------------------------------------------------------------------------------\r
-InternalMemSetMem16 PROC USES rdi\r
- mov rdi, rcx\r
- mov r9, rdi\r
- xor rcx, rcx\r
- sub rcx, rdi\r
- and rcx, 15\r
- mov rax, r8\r
- jz @F\r
- shr rcx, 1\r
- cmp rcx, rdx\r
- cmova rcx, rdx\r
- sub rdx, rcx\r
- rep stosw\r
-@@:\r
- mov rcx, rdx\r
- and edx, 7\r
- shr rcx, 3\r
- jz @SetWords\r
- movd xmm0, eax\r
- pshuflw xmm0, xmm0, 0\r
- movlhps xmm0, xmm0\r
-@@:\r
- movntdq [rdi], xmm0\r
- add rdi, 16\r
- loop @B\r
- mfence\r
-@SetWords:\r
- mov ecx, edx\r
- rep stosw\r
- mov rax, r9\r
- ret\r
-InternalMemSetMem16 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; SetMem32.asm\r
-;\r
-; Abstract:\r
-;\r
-; SetMem32 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID *\r
-; InternalMemSetMem32 (\r
-; IN VOID *Buffer,\r
-; IN UINTN Count,\r
-; IN UINT8 Value\r
-; )\r
-;------------------------------------------------------------------------------\r
-InternalMemSetMem32 PROC USES rdi\r
- mov rdi, rcx\r
- mov r9, rdi\r
- xor rcx, rcx\r
- sub rcx, rdi\r
- and rcx, 15\r
- mov rax, r8\r
- jz @F\r
- shr rcx, 2\r
- cmp rcx, rdx\r
- cmova rcx, rdx\r
- sub rdx, rcx\r
- rep stosd\r
-@@:\r
- mov rcx, rdx\r
- and edx, 3\r
- shr rcx, 2\r
- jz @SetDwords\r
- movd xmm0, eax\r
- pshufd xmm0, xmm0, 0\r
-@@:\r
- movntdq [rdi], xmm0\r
- add rdi, 16\r
- loop @B\r
- mfence\r
-@SetDwords:\r
- mov ecx, edx\r
- rep stosd\r
- mov rax, r9\r
- ret\r
-InternalMemSetMem32 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; SetMem64.asm\r
-;\r
-; Abstract:\r
-;\r
-; SetMem64 function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID *\r
-; InternalMemSetMem64 (\r
-; IN VOID *Buffer,\r
-; IN UINTN Count,\r
-; IN UINT64 Value\r
-; )\r
-;------------------------------------------------------------------------------\r
-InternalMemSetMem64 PROC\r
- mov rax, rcx ; rax <- Buffer\r
- xchg rcx, rdx ; rcx <- Count & rdx <- Buffer\r
- test dl, 8\r
- movd xmm0, r8\r
- jz @F\r
- mov [rdx], r8\r
- add rdx, 8\r
- dec rcx\r
-@@:\r
- shr rcx, 1\r
- jz @SetQwords\r
- movlhps xmm0, xmm0\r
-@@:\r
- movntdq [rdx], xmm0\r
- lea rdx, [rdx + 16]\r
- loop @B\r
- mfence\r
-@SetQwords:\r
- jnc @F\r
- mov [rdx], r8\r
-@@:\r
- ret\r
-InternalMemSetMem64 ENDP\r
-\r
- END\r
+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; ZeroMem.asm\r
-;\r
-; Abstract:\r
-;\r
-; ZeroMem function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID *\r
-; InternalMemZeroMem (\r
-; IN VOID *Buffer,\r
-; IN UINTN Count\r
-; )\r
-;------------------------------------------------------------------------------\r
-InternalMemZeroMem PROC USES rdi\r
- mov rdi, rcx\r
- xor rcx, rcx\r
- xor eax, eax\r
- sub rcx, rdi\r
- and rcx, 15\r
- mov r8, rdi\r
- jz @F\r
- cmp rcx, rdx\r
- cmova rcx, rdx\r
- sub rdx, rcx\r
- rep stosb\r
-@@:\r
- mov rcx, rdx\r
- and edx, 15\r
- shr rcx, 4\r
- jz @ZeroBytes\r
- pxor xmm0, xmm0\r
-@@:\r
- movntdq [rdi], xmm0 ; rdi should be 16-byte aligned\r
- add rdi, 16\r
- loop @B\r
- mfence\r
-@ZeroBytes:\r
- mov ecx, edx\r
- rep stosb\r
- mov rax, r8\r
- ret\r
-InternalMemZeroMem ENDP\r
-\r
- END\r