]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1.BaseMemoryLibMmx: Add X64 Cpu Arch support.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 28 Jun 2006 09:41:50 +0000 (09:41 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 28 Jun 2006 09:41:50 +0000 (09:41 +0000)
2.BasePrintLib: Fix some minor bugs

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@651 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.msa
MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm [new file with mode: 0644]
MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm [new file with mode: 0644]
MdePkg/Library/BasePrintLib/PrintLib.c
MdePkg/Library/BasePrintLib/PrintLibInternal.c

index d212557777940c71f894ea10c368ca805d381a38..c0e89c3ffcd98e098895629e17f128fc5d9cdfec 100644 (file)
@@ -36,19 +36,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     <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
@@ -61,6 +61,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
       <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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm
new file mode 100644 (file)
index 0000000..b8e289b
--- /dev/null
@@ -0,0 +1,43 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm
new file mode 100644 (file)
index 0000000..372c365
--- /dev/null
@@ -0,0 +1,68 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm
new file mode 100644 (file)
index 0000000..6af88fa
--- /dev/null
@@ -0,0 +1,42 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm
new file mode 100644 (file)
index 0000000..f9c9feb
--- /dev/null
@@ -0,0 +1,42 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm
new file mode 100644 (file)
index 0000000..2f286c9
--- /dev/null
@@ -0,0 +1,42 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm
new file mode 100644 (file)
index 0000000..4027ece
--- /dev/null
@@ -0,0 +1,42 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm
new file mode 100644 (file)
index 0000000..9688c3d
--- /dev/null
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm
new file mode 100644 (file)
index 0000000..a950208
--- /dev/null
@@ -0,0 +1,48 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm
new file mode 100644 (file)
index 0000000..d835543
--- /dev/null
@@ -0,0 +1,47 @@
+;------------------------------------------------------------------------------\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
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm
new file mode 100644 (file)
index 0000000..5780647
--- /dev/null
@@ -0,0 +1,39 @@
+;------------------------------------------------------------------------------\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
index bbafeeaec53d54f42b89b7bc599d1bd6dc8dba86..1484d891b63f284ba6df8e31f620ea5d8822208c 100644 (file)
@@ -227,6 +227,17 @@ BasePrintLibVSPrint (
             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
@@ -299,19 +310,26 @@ BasePrintLibVSPrint (
           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
index 9314b609119626be20906b5a00325b4a65eab4a1..30b4539141d5bc5dbfc22f8cc919a8db2cf82ca1 100644 (file)
@@ -158,6 +158,7 @@ BasePrintLibConvertValueToString (
   if (Value < 0) {\r
     Value = -Value;\r
     Buffer = BasePrintLibFillBuffer (Buffer, 1, '-', Increment);\r
+    Width--;\r
   }\r
 \r
   Count = BasePrintLibValueToString (ValueBuffer, Value, 10);\r
@@ -166,7 +167,10 @@ BasePrintLibConvertValueToString (
     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