<LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>\r
</LibraryClassDefinitions>\r
<SourceFiles>\r
+ <Filename>MemLibGuid.c</Filename>\r
+ <Filename>CopyMemWrapper.c</Filename>\r
+ <Filename>SetMemWrapper.c</Filename>\r
+ <Filename>SetMem16Wrapper.c</Filename>\r
+ <Filename>SetMem32Wrapper.c</Filename>\r
+ <Filename>SetMem64Wrapper.c</Filename>\r
+ <Filename>CompareMemWrapper.c</Filename>\r
+ <Filename>ZeroMemWrapper.c</Filename>\r
+ <Filename>ScanMem8Wrapper.c</Filename>\r
+ <Filename>ScanMem16Wrapper.c</Filename>\r
+ <Filename>ScanMem32Wrapper.c</Filename>\r
+ <Filename>ScanMem64Wrapper.c</Filename>\r
<Arch ArchType="IA32">\r
- <Filename>MemLibGuid.c</Filename>\r
- <Filename>CopyMemWrapper.c</Filename>\r
- <Filename>SetMemWrapper.c</Filename>\r
- <Filename>SetMem16Wrapper.c</Filename>\r
- <Filename>SetMem32Wrapper.c</Filename>\r
- <Filename>SetMem64Wrapper.c</Filename>\r
- <Filename>CompareMemWrapper.c</Filename>\r
- <Filename>ZeroMemWrapper.c</Filename>\r
- <Filename>ScanMem8Wrapper.c</Filename>\r
- <Filename>ScanMem16Wrapper.c</Filename>\r
- <Filename>ScanMem32Wrapper.c</Filename>\r
- <Filename>ScanMem64Wrapper.c</Filename>\r
<Filename>Ia32/CopyMem.asm</Filename>\r
<Filename>Ia32/SetMem.asm</Filename>\r
<Filename>Ia32/ZeroMem.asm</Filename>\r
<Filename>Ia32/ScanMem32.asm</Filename>\r
<Filename>Ia32/ScanMem64.asm</Filename>\r
</Arch>\r
+ <Arch ArchType="X64">\r
+ <Filename>X64/CopyMem.asm</Filename>\r
+ <Filename>X64/SetMem.asm</Filename>\r
+ <Filename>X64/SetMem16.asm</Filename>\r
+ <Filename>X64/SetMem32.asm</Filename>\r
+ <Filename>X64/SetMem64.asm</Filename>\r
+ <Filename>X64/CompareMem.asm</Filename>\r
+ <Filename>X64/ScanMem8.asm</Filename>\r
+ <Filename>X64/ScanMem16.asm</Filename>\r
+ <Filename>X64/ScanMem32.asm</Filename>\r
+ <Filename>X64/ScanMem64.asm</Filename>\r
+ </Arch>\r
</SourceFiles>\r
<Includes>\r
<PackageName>MdePkg</PackageName>\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 share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemCopyMem PROC USES rsi rdi\r
+ mov rsi, rdx ; rsi <- Source\r
+ mov rdi, rcx ; rdi <- Destination\r
+ lea r9, [rdi + r8 - 1] ; r9 <- End of Destination\r
+ cmp rsi, rdi\r
+ mov rax, rdi ; rax <- Destination as return value\r
+ jae @F\r
+ cmp r9, rsi\r
+ jae @CopyBackward ; Copy backward if overlapped\r
+@@:\r
+ xor rcx, rcx\r
+ sub rcx, rsi\r
+ and rcx, 7 ; rcx + rsi aligns on 8-byte boundary\r
+ jz @F\r
+ cmp rcx, r8\r
+ cmova rcx, r8\r
+ sub r8, rcx ; r8 <- remaining bytes to copy\r
+ rep movsb\r
+@@:\r
+ mov rcx, r8\r
+ and r8, 7\r
+ shr rcx, 3 ; rcx <- # of Qwords to copy\r
+ jz @CopyBytes\r
+@@:\r
+ DB 48h, 0fh, 6fh, 06h ; movq mm0, [rsi]\r
+ DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0\r
+ add rsi, 8\r
+ add rdi, 8\r
+ loop @B\r
+ mfence\r
+ jmp @CopyBytes\r
+@CopyBackward:\r
+ mov rdi, r9 ; rdi <- End of Destination\r
+ lea rsi, [rsi + r8 - 1] ; rsi <- End of Source\r
+ std ; set direction flag\r
+@CopyBytes:\r
+ mov rcx, r8\r
+ rep movsb ; Copy bytes backward\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 share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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 share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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 share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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 share the same version of this file:\r
+;\r
+; BaseMemoryLibRepStr\r
+; BaseMemoryLibMmx\r
+; BaseMemoryLibSse2\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ .code\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
+InternalMemSetMem PROC USES rdi\r
+ mov rax, r8\r
+ mov ah, al\r
+ DB 48h, 0fh, 6eh, 0c0h ; movq mm0, rax\r
+ mov r8, rcx\r
+ mov rdi, r8\r
+ mov rcx, rdx\r
+ shr rcx, 3\r
+ jz @SetBytes\r
+ DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h\r
+@@: \r
+ DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0\r
+ add rdi, 8\r
+ loop @B\r
+ mfence\r
+@SetBytes:\r
+ and rdx, 7\r
+ mov rcx, rdx\r
+ rep stosb\r
+ mov rax, r8\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
+InternalMemSetMem16 PROC USES rdi\r
+ mov rax, r8\r
+ DB 48h, 0fh, 6eh, 0c0h ; movq mm0, rax\r
+ mov r8, rcx\r
+ mov rdi, r8\r
+ mov rcx, rdx\r
+ and rdx, 3\r
+ shr rcx, 2\r
+ jz @SetWords\r
+ DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h\r
+@@: \r
+ DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0\r
+ add rdi, 8\r
+ loop @B\r
+ mfence\r
+@SetWords:\r
+ mov rcx, rdx\r
+ rep stosw\r
+ mov rax, r8\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
+InternalMemSetMem32 PROC USES rdi\r
+ DB 49h, 0fh, 6eh, 0c0h ; movq mm0, r8 ; mm0 <- Value\r
+ mov rax, rcx ; rax <- Buffer\r
+ mov rdi, rax\r
+ mov rcx, rdx\r
+ shr rcx, 1 \r
+ jz @SetDwords\r
+ DB 0fh, 70h, 0C0h, 44h ; pshufw mm0, mm0, 44h\r
+@@:\r
+ DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0\r
+ add rdi, 8\r
+ loop @B\r
+ mfence\r
+@SetDwords:\r
+ test dl, 1\r
+ jz @F\r
+ DB 0fh, 7eh, 07h ; movd [rdi], mm0\r
+@@:\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
+InternalMemSetMem64 PROC USES rdi\r
+ DB 49h, 0fh, 6eh, 0c0h; movq mm0, r8 ; mm0 <- Value\r
+ mov rax, rcx ; rax <- Buffer\r
+ xchg rcx, rdx ; rcx <- Count\r
+ mov rdi, rax\r
+@@:\r
+ DB 48h, 0fh, 0e7h, 07h; movntq [rdi], mm0\r
+ add rdi, 8\r
+ loop @B\r
+ mfence\r
+ ret\r
+InternalMemSetMem64 ENDP\r
+\r
+ END\r
Precision = Count;\r
}\r
break;\r
+ \r
+ case '\0':\r
+ //\r
+ // Make no output if Format string terminates unexpectedly when\r
+ // looking up for flag, width, precision and type. \r
+ //\r
+ Format -= BytesPerFormatCharacter;\r
+ Precision = 0;\r
+ //\r
+ // break skiped on purpose.\r
+ //\r
default:\r
Done = TRUE;\r
break;\r
Count = 0;\r
}\r
ArgumentString = (CHAR8 *)ValueBuffer + Count;\r
- Digits = 3 - (Count % 3);\r
+ \r
+ Digits = Count % 3;\r
+ if (Digits != 0) {\r
+ Digits = 3 - Digits;\r
+ }\r
if (Comma && Count != 0) {\r
Count += ((Count - 1) / 3);\r
}\r
if (Prefix != 0) {\r
Count++;\r
+ Precision++;\r
}\r
Flags |= ARGUMENT_REVERSED;\r
ZeroPad = TRUE;\r
if ((Flags & PREFIX_ZERO) != 0) {\r
- if ((Flags & PAD_TO_WIDTH) != 0) {\r
- if ((Flags & PRECISION) == 0) {\r
- Precision = Width;\r
+ if ((Flags & LEFT_JUSTIFY) == 0) {\r
+ if ((Flags & PAD_TO_WIDTH) != 0) {\r
+ if ((Flags & PRECISION) == 0) {\r
+ Precision = Width;\r
+ }\r
}\r
}\r
}\r
if (Value < 0) {\r
Value = -Value;\r
Buffer = BasePrintLibFillBuffer (Buffer, 1, '-', Increment);\r
+ Width--;\r
}\r
\r
Count = BasePrintLibValueToString (ValueBuffer, Value, 10);\r
Buffer = BasePrintLibFillBuffer (Buffer, Width - Count, '0', Increment);\r
}\r
\r
- Digits = 3 - (Count % 3);\r
+ Digits = Count % 3;\r
+ if (Digits != 0) {\r
+ Digits = 3 - Digits;\r
+ }\r
for (Index = 0; Index < Count; Index++) {\r
Buffer = BasePrintLibFillBuffer (Buffer, 1, ValueBuffer[Count - Index], Increment);\r
if ((Flags & COMMA_TYPE) != 0) {\r