summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c4
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.msa1
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.S16
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.S32
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm27
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.S16
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.S14
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.S18
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.S14
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.S39
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.asm28
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.S27
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.asm16
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.S41
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.asm34
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.S25
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.asm8
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.S18
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm34
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm23
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm21
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm30
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm21
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm54
-rw-r--r--MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c4
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S21
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S45
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm16
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S21
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S21
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S30
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S21
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S13
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm8
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S20
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm8
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S12
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm8
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S19
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm8
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S11
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm7
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c4
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm15
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm8
-rw-r--r--MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm7
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.S14
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.S31
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.asm12
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.S14
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.S16
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.S18
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.S14
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.S14
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.asm5
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.S13
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.asm5
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.S17
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.asm5
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.S17
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.asm5
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.S17
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.asm5
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c4
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/CompareMem.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/CopyMem.asm13
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem16.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem32.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem64.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem8.asm9
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/SetMem.asm2
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/SetMem16.asm2
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/SetMem32.asm2
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/SetMem64.asm6
-rw-r--r--MdePkg/Library/BaseMemoryLibSse2/x64/ZeroMem.asm2
-rw-r--r--MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c4
-rw-r--r--MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c4
106 files changed, 1002 insertions, 453 deletions
diff --git a/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c
index 08247681c5..e2ffb5c3c2 100644
--- a/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c
+++ b/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c
@@ -30,7 +30,7 @@
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with zeros.
@param Length Number of bytes in Buffer to fill with zeros.
@@ -47,5 +47,5 @@ ZeroMem (
{
ASSERT (!(Buffer == NULL && Length > 0));
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
- return InternalMemSetMem (Buffer, Length, 0);
+ return InternalMemZeroMem (Buffer, Length);
}
diff --git a/MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.msa b/MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.msa
index 978a3628a6..78eae20544 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.msa
+++ b/MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.msa
@@ -89,6 +89,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Filename SupArchList="X64">X64/ScanMem16.asm</Filename>
<Filename SupArchList="X64">X64/ScanMem32.asm</Filename>
<Filename SupArchList="X64">X64/ScanMem64.asm</Filename>
+ <Filename SupArchList="X64">X64/ZeroMem.asm</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.S
index c7e0b8a2a1..7901b82a44 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemCompareMem
+
+#------------------------------------------------------------------------------
+# INTN
+# EFIAPI
+# InternalMemCompareMem (
+# IN CONST VOID *DestinationBuffer,
+# IN CONST VOID *SourceBuffer,
+# IN UINTN Length
+# );
+#------------------------------------------------------------------------------
_InternalMemCompareMem:
push %esi
push %edi
@@ -45,5 +51,3 @@ _InternalMemCompareMem:
pop %edi
pop %esi
ret
-
-
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.asm
index 3cf6fe7f73..1d0e7fad39 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CompareMem.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCompareMem PROC USES esi edi
mov esi, [esp + 12]
mov edi, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.S
index fff8bde5ea..d644b34675 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.S
@@ -21,32 +21,29 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemCopyMem
#------------------------------------------------------------------------------
# VOID *
-# _mem_CopyMem (
+# EFIAPI
+# InternalMemCopyMem (
# IN VOID *Destination,
# IN VOID *Source,
# IN UINTN Count
-# )
+# );
#------------------------------------------------------------------------------
-.global _InternalMemCopyMem
_InternalMemCopyMem:
push %esi
push %edi
movl 16(%esp), %esi # esi <- Source
movl 12(%esp), %edi # edi <- Destination
movl 20(%esp), %edx # edx <- Count
- leal -1(%edi,%edx,), %eax # eax <- End of Destination
+ leal -1(%esi,%edx,), %eax # eax <- End of Source
cmpl %edi, %esi
jae L0
- cmpl %esi, %eax # Overlapped?
+ cmpl %edi, %eax # Overlapped?
jae @CopyBackward # Copy backward if overlapped
-L0:
+L0:
xorl %ecx, %ecx
subl %esi, %ecx
andl $7, %ecx # ecx + esi aligns on 8-byte boundary
@@ -56,7 +53,7 @@ L0:
subl %ecx, %edx # edx <- remaining bytes to copy
rep
movsb
-L1:
+L1:
movl %edx, %ecx
andl $7, %edx
shrl $3, %ecx # ecx <- # of Qwords to copy
@@ -64,22 +61,21 @@ L1:
pushl %eax
pushl %eax
movq %mm0, (%esp) # save mm0
-L2:
+L2:
movq (%esi), %mm0
- movntq %mm0, (%edi)
+ movq %mm0, (%edi)
addl $8, %esi
addl $8, %edi
loop L2
- mfence
movq (%esp), %mm0 # restore mm0
popl %ecx # stack cleanup
popl %ecx # stack cleanup
jmp @CopyBytes
-@CopyBackward:
- movl %eax, %edi # edi <- Last byte in Destination
- leal -1(%esi,%edx,), %esi # esi <- Last byte in Source
+@CopyBackward:
+ movl %eax, %esi # esi <- Last byte in Source
+ leal -1(%edi,%edx,), %edi # edi <- Last byte in Destination
std
-@CopyBytes:
+@CopyBytes:
movl %edx, %ecx
rep
movsb
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm
index b709a809d5..1b8b3c5dcd 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm
@@ -23,36 +23,28 @@
.686
.model flat,C
- .xmm
+ .mmx
.code
;------------------------------------------------------------------------------
; VOID *
-; _mem_CopyMem (
+; EFIAPI
+; InternalMemCopyMem (
; IN VOID *Destination,
; IN VOID *Source,
; IN UINTN Count
-; )
+; );
;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES esi edi
mov esi, [esp + 16] ; esi <- Source
mov edi, [esp + 12] ; edi <- Destination
mov edx, [esp + 20] ; edx <- Count
- lea eax, [edi + edx - 1] ; eax <- End of Destination
+ lea eax, [esi + edx - 1] ; eax <- End of Source
cmp esi, edi
jae @F
- cmp eax, esi ; Overlapped?
+ cmp eax, edi ; Overlapped?
jae @CopyBackward ; Copy backward if overlapped
@@:
- xor ecx, ecx
- sub ecx, esi
- and ecx, 7 ; ecx + esi aligns on 8-byte boundary
- jz @F
- cmp ecx, edx
- cmova ecx, edx
- sub edx, ecx ; edx <- remaining bytes to copy
- rep movsb
-@@:
mov ecx, edx
and edx, 7
shr ecx, 3 ; ecx <- # of Qwords to copy
@@ -62,18 +54,17 @@ InternalMemCopyMem PROC USES esi edi
movq [esp], mm0 ; save mm0
@@:
movq mm0, [esi]
- movntq [edi], mm0
+ movq [edi], mm0
add esi, 8
add edi, 8
loop @B
- mfence
movq mm0, [esp] ; restore mm0
pop ecx ; stack cleanup
pop ecx ; stack cleanup
jmp @CopyBytes
@CopyBackward:
- mov edi, eax ; edi <- Last byte in Destination
- lea esi, [esi + edx - 1] ; esi <- Last byte in Source
+ mov esi, eax ; esi <- Last byte in Source
+ lea edi, [edi + edx - 1] ; edi <- Last byte in Destination
std
@CopyBytes:
mov ecx, edx
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.S
index e23799e773..1e83064573 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem16
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem16 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT16 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem16:
push %edi
movl 12(%esp), %ecx
@@ -42,5 +48,3 @@ _InternalMemScanMem16:
cmovnz %ecx, %eax
pop %edi
ret
-
-
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.asm
index 7071942ede..57fab61b77 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem16.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem16 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.S
index 6b4a919dde..b7b93d9c0c 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem32
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem32 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT32 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem32:
push %edi
movl 12(%esp), %ecx
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.asm
index e6aaf02bc3..6ac857ce16 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem32.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem32 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.S
index 00f6d74436..6bbb18a334 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.S
@@ -27,18 +27,24 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem64
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem64 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT64 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem64:
push %edi
movl 12(%esp), %ecx
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 8(%esp), %edi
-L0:
+L0:
cmpl (%edi), %eax
leal 8(%edi), %edi
loopne L0
@@ -46,7 +52,7 @@ L0:
cmpl -4(%edi), %edx
jecxz L1
jne L0
-L1:
+L1:
leal -8(%edi), %eax
cmovne %ecx, %eax
pop %edi
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.asm
index f9725a4a5d..ca54f13738 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem64.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem64 PROC USES edi
mov ecx, [esp + 12]
mov eax, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.S
index 57640378b4..fe678fac26 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem8
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem8 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT8 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem8:
push %edi
movl 12(%esp), %ecx
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.asm
index 6ae1900189..a3f65b64fa 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ScanMem8.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem8 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.S
index 8a893f893a..4e93915caa 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.S
@@ -21,44 +21,43 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemSetMem
#------------------------------------------------------------------------------
# VOID *
-# _mem_SetMem (
+# InternalMemSetMem (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT8 Value
# )
#------------------------------------------------------------------------------
-.global _InternalMemSetMem
_InternalMemSetMem:
push %edi
+ movb 16(%esp), %al
+ movb %al, %ah
+ shrdl $16, %eax, %edx
+ shldl $16, %edx, %eax
movl 12(%esp), %ecx # ecx <- Count
movl 8(%esp), %edi # edi <- Buffer
movl %ecx, %edx
+ andl $7, %edx
shrl $3, %ecx # # of Qwords to set
- movb 16(%esp), %al # al <- Value
- jz @SetBytes
- movb %al, %ah # ax <- Value | (Value << 8)
- pushl %ecx
- pushl %ecx
+ jz L1
+ addl $0x-10, %esp
movq %mm0, (%esp) # save mm0
+ movq %mm1, 8(%esp) # save mm1
movd %eax, %mm0
- pshufw $0x0,%mm0,%mm0
-L0:
- movntq %mm0, (%edi)
+ movd %eax, %mm1
+ psllq $32, %mm0
+ por %mm1, %mm0 # fill mm0 with 8 Value's
+L0:
+ movq %mm0, (%edi)
addl $8, %edi
- loop L0
- mfence
+ loopl L0
movq (%esp), %mm0 # restore mm0
- popl %ecx # stack cleanup
- popl %ecx
-@SetBytes:
- andl $7, %edx
+ movq 8(%esp), %mm1 # restore mm1
+ addl $0x10, %esp # stack cleanup
+L1:
movl %edx, %ecx
rep
stosb
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.asm
index f2c55f1296..c9c48ecf9d 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.asm
@@ -23,40 +23,44 @@
.686
.model flat,C
- .xmm
+ .mmx
.code
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem (
+; EFIAPI
+; InternalMemSetMem (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT8 Value
; )
;------------------------------------------------------------------------------
InternalMemSetMem PROC USES edi
+ mov al, [esp + 16]
+ mov ah, al
+ shrd edx, eax, 16
+ shld eax, edx, 16
mov ecx, [esp + 12] ; ecx <- Count
mov edi, [esp + 8] ; edi <- Buffer
mov edx, ecx
+ and edx, 7
shr ecx, 3 ; # of Qwords to set
- mov al, [esp + 16] ; al <- Value
jz @SetBytes
- mov ah, al ; ax <- Value | (Value << 8)
- push ecx
- push ecx
+ add esp, -10h
movq [esp], mm0 ; save mm0
+ movq [esp + 8], mm1 ; save mm1
movd mm0, eax
- pshufw mm0, mm0, 0 ; fill mm0 with 8 Value's
+ movd mm1, eax
+ psllq mm0, 32
+ por mm0, mm1 ; fill mm0 with 8 Value's
@@:
- movntq [edi], mm0
+ movq [edi], mm0
add edi, 8
loop @B
- mfence
movq mm0, [esp] ; restore mm0
- pop ecx ; stack cleanup
- pop ecx
+ movq mm1, [esp + 8] ; restore mm1
+ add esp, 10h ; stack cleanup
@SetBytes:
- and edx, 7
mov ecx, edx
rep stosb
mov eax, [esp + 8] ; eax <- Buffer as return value
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.S
index bcbd49e442..9898d28f98 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.S
@@ -21,37 +21,36 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemSetMem16
#------------------------------------------------------------------------------
# VOID *
-# _mem_SetMem16 (
+# InternalMemSetMem16 (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT16 Value
# )
#------------------------------------------------------------------------------
-.global _InternalMemSetMem16
_InternalMemSetMem16:
push %edi
+ movl 16(%esp), %eax
+ shrdl $16, %eax, %edx
+ shldl $16, %edx, %eax
movl 12(%esp), %edx
movl 8(%esp), %edi
movl %edx, %ecx
andl $3, %edx
shrl $2, %ecx
- movl 16(%esp), %eax
- jz @SetWords
+ jz L1
movd %eax, %mm0
- pshufw $0, %mm0, %mm0
-L0:
- movntq %mm0, (%edi)
+ movd %eax, %mm1
+ psllq $32, %mm0
+ por %mm1, %mm0
+L0:
+ movq %mm0, (%edi)
addl $8, %edi
- loop L0
- mfence
-@SetWords:
+ loopl L0
+L1:
movl %edx, %ecx
rep
stosw
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.asm
index f9dc533fd8..e934226658 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem16.asm
@@ -23,32 +23,36 @@
.686
.model flat,C
- .xmm
+ .mmx
.code
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem16 (
+; EFIAPI
+; InternalMemSetMem16 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT16 Value
; )
;------------------------------------------------------------------------------
InternalMemSetMem16 PROC USES edi
+ mov eax, [esp + 16]
+ shrd edx, eax, 16
+ shld eax, edx, 16
mov edx, [esp + 12]
mov edi, [esp + 8]
mov ecx, edx
and edx, 3
shr ecx, 2
- mov eax, [esp + 16]
jz @SetWords
movd mm0, eax
- pshufw mm0, mm0, 0
+ movd mm1, eax
+ psllq mm0, 32
+ por mm0, mm1
@@:
- movntq [edi], mm0
+ movq [edi], mm0
add edi, 8
loop @B
- mfence
@SetWords:
mov ecx, edx
rep stosw
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.S
index 27fd6174bd..8281652ad9 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.S
@@ -21,39 +21,32 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemSetMem32
#------------------------------------------------------------------------------
# VOID *
-# _mem_SetMem32 (
+# InternalMemSetMem32 (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT32 Value
# )
#------------------------------------------------------------------------------
-.global _InternalMemSetMem32
_InternalMemSetMem32:
- push %edi
- movl 12(%esp), %edx
- movl 8(%esp), %edi
- movl %edx, %ecx
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ movd 12(%esp), %mm0
shrl %ecx
- movd 16(%esp), %mm0
- movl %edi, %eax
- jz @SetDwords
- pshufw $0x44, %mm0, %mm0
-L0:
- movntq %mm0, (%edi)
- addl $8, %edi
- loopl L0
- mfence
-@SetDwords:
- testb $1, %dl
+ movl %eax, %edx
jz L1
- movd %mm0, (%edi)
-L1:
- pop %edi
+ movq %mm0, %mm1
+ psllq $32, %mm1
+ por %mm1, %mm0
+L0:
+ movq %mm0, (%edx)
+ lea 8(%edx), %edx
+ loopl L0
+L1:
+ jnc L2
+ movd %mm0, (%edx)
+L2:
ret
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.asm
index 7f24fcd744..c2e4869e47 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem32.asm
@@ -23,35 +23,35 @@
.686
.model flat,C
- .xmm
+ .mmx
.code
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem32 (
+; EFIAPI
+; InternalMemSetMem32 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT32 Value
-; )
+; );
;------------------------------------------------------------------------------
-InternalMemSetMem32 PROC USES edi
- mov edx, [esp + 12]
- mov edi, [esp + 8]
- mov ecx, edx
- shr ecx, 1
- movd mm0, [esp + 16]
- mov eax, edi
+InternalMemSetMem32 PROC
+ mov eax, [esp + 4] ; eax <- Buffer as return value
+ mov ecx, [esp + 8] ; ecx <- Count
+ movd mm0, [esp + 12] ; mm0 <- Value
+ shr ecx, 1 ; ecx <- number of qwords to set
+ mov edx, eax ; edx <- Buffer
jz @SetDwords
- pshufw mm0, mm0, 44h
+ movq mm1, mm0
+ psllq mm1, 32
+ por mm0, mm1
@@:
- movntq [edi], mm0
- add edi, 8
+ movq [edx], mm0
+ lea edx, [edx + 8] ; use "lea" to avoid change in flags
loop @B
- mfence
@SetDwords:
- test dl, 1
- jz @F
- movd [edi], mm0
+ jnc @F
+ movd [edx], mm0
@@:
ret
InternalMemSetMem32 ENDP
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.S
index 9699581606..5eef027e57 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.S
@@ -21,30 +21,23 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemSetMem64
#------------------------------------------------------------------------------
# VOID *
-# _mem_SetMem64 (
+# InternalMemSetMem64 (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT64 Value
# )
#------------------------------------------------------------------------------
-.global _InternalMemSetMem64
_InternalMemSetMem64:
- push %edi
- movq 16(%esp), %mm0
- movl 12(%esp), %ecx
- movl 8(%esp), %edi
- movl %edi, %eax
-L0:
- movntq %mm0, (%edi)
- addl $8, %edi
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ movq 12(%esp), %mm0
+ movl %eax, %edx
+L0:
+ movq %mm0, (%edx)
+ lea 8(%edx), %edx
loopl L0
- mfence
- pop %edi
ret
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.asm
index 310f418d0c..027483ba3f 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem64.asm
@@ -23,12 +23,13 @@
.686
.model flat,C
- .xmm
+ .mmx
.code
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem64 (
+; EFIAPI
+; InternalMemSetMem64 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT64 Value
@@ -40,10 +41,9 @@ InternalMemSetMem64 PROC
movq mm0, [esp + 12]
mov edx, eax
@@:
- movntq [edx], mm0
+ movq [edx], mm0
add edx, 8
loop @B
- mfence
ret
InternalMemSetMem64 ENDP
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.S b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.S
index 0bb19c7da2..f51ce8f98e 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.S
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.S
@@ -21,19 +21,16 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemZeroMem
#------------------------------------------------------------------------------
# VOID *
-# _mem_ZeroMem (
+# EFIAPI
+# InternalMemZeroMem (
# IN VOID *Buffer,
# IN UINTN Count
-# )
+# );
#------------------------------------------------------------------------------
-.global _InternalMemZeroMem
_InternalMemZeroMem:
push %edi
movl 8(%esp), %edi
@@ -42,12 +39,11 @@ _InternalMemZeroMem:
shrl $3, %ecx
jz @ZeroBytes
pxor %mm0, %mm0
-L0:
- movntq %mm0, (%edi)
+L0:
+ movq %mm0, (%edi)
addl $8, %edi
loop L0
- mfence
-@ZeroBytes:
+@ZeroBytes:
andl $7, %edx
xorl %eax, %eax
movl %edx, %ecx
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.asm
index 31ef120525..a75480bd40 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/Ia32/ZeroMem.asm
@@ -23,15 +23,15 @@
.686
.model flat,C
- .xmm
+ .mmx
.code
;------------------------------------------------------------------------------
; VOID *
-; _mem_ZeroMem (
+; InternalMemZeroMem (
; IN VOID *Buffer,
; IN UINTN Count
-; )
+; );
;------------------------------------------------------------------------------
InternalMemZeroMem PROC USES edi
mov edi, [esp + 8]
@@ -41,10 +41,9 @@ InternalMemZeroMem PROC USES edi
jz @ZeroBytes
pxor mm0, mm0
@@:
- movntq [edi], mm0
+ movq [edi], mm0
add edi, 8
loop @B
- mfence
@ZeroBytes:
and edx, 7
xor eax, eax
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm
index b8e289bb27..554bc07c64 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/CompareMem.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCompareMem PROC USES rsi rdi
mov rsi, rcx
mov rdi, rdx
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm
index 801cf92750..b57192edbe 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.asm
@@ -23,42 +23,42 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemCopyMem (
+; OUT VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES rsi rdi
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
- lea r9, [rdi + r8 - 1] ; r9 <- End of 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, rsi
+ cmp r9, rdi
jae @CopyBackward ; Copy backward if overlapped
@@:
- xor rcx, rcx
- sub rcx, rsi
- and rcx, 7 ; rcx + rsi aligns on 8-byte boundary
- jz @F
- cmp rcx, r8
- cmova rcx, r8
- sub r8, rcx ; r8 <- remaining bytes to copy
- rep movsb
-@@:
mov rcx, r8
and r8, 7
shr rcx, 3 ; rcx <- # of Qwords to copy
jz @CopyBytes
- DB 49h, 0fh, 7eh, 0c2h ; movq r10, mm0 ; save mm0
+ DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10)
@@:
- DB 48h, 0fh, 6fh, 06h ; movq mm0, [rsi]
- DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0
+ DB 0fh, 6fh, 06h ; movd mm0, [rsi]
+ DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
add rsi, 8
add rdi, 8
loop @B
mfence
- DB 49h, 0fh, 6eh, 0c2h ; movq mm0, r10 ; restore mm0
+ DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0)
jmp @CopyBytes
@CopyBackward:
- mov rdi, r9 ; rdi <- End of Destination
- lea rsi, [rsi + r8 - 1] ; rsi <- End of Source
+ mov rsi, r9 ; rsi <- End of Source
+ lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination
std ; set direction flag
@CopyBytes:
mov rcx, r8
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm
index 6af88fae5b..a2538c2cca 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem16.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem16 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm
index f9c9feb00e..e0523d8547 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem32.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem32 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm
index 2f286c9e2f..0e7e9c782f 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem64.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem64 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm
index 4027ece768..879273f960 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/ScanMem8.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem8 PROC USES rdi
mov rdi, rcx
mov rcx, rdx
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm
index 9688c3d65b..923beef6c1 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.asm
@@ -23,24 +23,33 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem (
+; OUT VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemSetMem PROC USES rdi
mov rax, r8
mov ah, al
- DB 48h, 0fh, 6eh, 0c0h ; movq mm0, rax
+ DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax
mov r8, rcx
- mov rdi, r8
+ 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, 0e7h, 07h ; movntq [rdi], mm0
+ DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
+@@:
+ DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
add rdi, 8
loop @B
mfence
@SetBytes:
- and rdx, 7
- mov rcx, rdx
+ mov ecx, edx
rep stosb
mov rax, r8
ret
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm
index a95020876c..01b72c55d5 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem16.asm
@@ -23,23 +23,32 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem16 (
+; OUT VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemSetMem16 PROC USES rdi
mov rax, r8
- DB 48h, 0fh, 6eh, 0c0h ; movq mm0, rax
+ DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax
mov r8, rcx
mov rdi, r8
mov rcx, rdx
- and rdx, 3
+ and edx, 3
shr rcx, 2
jz @SetWords
- DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
-@@:
- DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0
+ DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
+@@:
+ DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
add rdi, 8
loop @B
mfence
@SetWords:
- mov rcx, rdx
+ mov ecx, edx
rep stosw
mov rax, r8
ret
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm
index d835543767..89cf175608 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.asm
@@ -23,23 +23,29 @@
.code
-InternalMemSetMem32 PROC USES rdi
- DB 49h, 0fh, 6eh, 0c0h ; movq mm0, r8 ; mm0 <- Value
- mov rax, rcx ; rax <- Buffer
- mov rdi, rax
- mov rcx, rdx
- shr rcx, 1
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem32 PROC
+ DB 49h, 0fh, 6eh, 0c0h ; movd mm0, r8 (Value)
+ mov rax, rcx ; rax <- Buffer
+ xchg rcx, rdx ; rcx <- Count rdx <- Buffer
+ shr rcx, 1 ; rcx <- # of qwords to set
jz @SetDwords
- DB 0fh, 70h, 0C0h, 44h ; pshufw mm0, mm0, 44h
+ DB 0fh, 70h, 0C0h, 44h ; pshufw mm0, mm0, 44h
@@:
- DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0
- add rdi, 8
+ DB 0fh, 0e7h, 02h ; movntq [rdx], mm0
+ lea rdx, [rdx + 8] ; use "lea" to avoid flag changes
loop @B
mfence
@SetDwords:
- test dl, 1
- jz @F
- DB 0fh, 7eh, 07h ; movd [rdi], mm0
+ jnc @F
+ DB 0fh, 7eh, 02h ; movd [rdx], mm0
@@:
ret
InternalMemSetMem32 ENDP
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm
index 5780647445..454d6234bf 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/SetMem64.asm
@@ -23,14 +23,21 @@
.code
-InternalMemSetMem64 PROC USES rdi
- DB 49h, 0fh, 6eh, 0c0h; movq mm0, r8 ; mm0 <- Value
- mov rax, rcx ; rax <- Buffer
- xchg rcx, rdx ; rcx <- Count
- mov rdi, rax
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem64 PROC
+ DB 49h, 0fh, 6eh, 0c0h ; movd mm0, r8 (Value)
+ mov rax, rcx ; rax <- Buffer
+ xchg rcx, rdx ; rcx <- Count
@@:
- DB 48h, 0fh, 0e7h, 07h; movntq [rdi], mm0
- add rdi, 8
+ DB 0fh, 0e7h, 02h ; movntq [rdx], mm0
+ add rdx, 8
loop @B
mfence
ret
diff --git a/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm
new file mode 100644
index 0000000000..e9035a3c14
--- /dev/null
+++ b/MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm
@@ -0,0 +1,54 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, 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 *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMemZeroMem 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 0fh, 0e7h, 7 ; movntq [rdi], mm0
+ add rdi, 8
+ loop @B
+ DB 0fh, 0aeh, 0f0h ; mfence
+@ZeroBytes:
+ xor eax, eax
+ mov ecx, edx
+ rep stosb
+ mov rax, r8
+ ret
+InternalMemZeroMem ENDP
+
+ END
diff --git a/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c
index 08247681c5..e2ffb5c3c2 100644
--- a/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c
+++ b/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c
@@ -30,7 +30,7 @@
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with zeros.
@param Length Number of bytes in Buffer to fill with zeros.
@@ -47,5 +47,5 @@ ZeroMem (
{
ASSERT (!(Buffer == NULL && Length > 0));
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
- return InternalMemSetMem (Buffer, Length, 0);
+ return InternalMemZeroMem (Buffer, Length);
}
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S
index b48b8f0f1c..7901b82a44 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S
@@ -27,20 +27,27 @@
#
#------------------------------------------------------------------------------
- .686:
- .code:
-
.global _InternalMemCompareMem
+
+#------------------------------------------------------------------------------
+# INTN
+# EFIAPI
+# InternalMemCompareMem (
+# IN CONST VOID *DestinationBuffer,
+# IN CONST VOID *SourceBuffer,
+# IN UINTN Length
+# );
+#------------------------------------------------------------------------------
_InternalMemCompareMem:
push %esi
push %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
+ movl 12(%esp), %esi
+ movl 16(%esp), %edi
+ movl 20(%esp), %ecx
repe cmpsb
movzbl -1(%esi), %eax
movzbl -1(%edi), %edx
- subl %edx,%eax
+ subl %edx, %eax
pop %edi
pop %esi
ret
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm
index 3cf6fe7f73..1d0e7fad39 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCompareMem PROC USES esi edi
mov esi, [esp + 12]
mov edi, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S
index e80a00deb4..42695b28c4 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S
@@ -21,38 +21,45 @@
#
#------------------------------------------------------------------------------
- .386:
- .code:
-
.global _InternalMemCopyMem
+
+#------------------------------------------------------------------------------
+# VOID *
+# EFIAPI
+# InternalMemCopyMem (
+# IN VOID *Destination,
+# IN VOID *Source,
+# IN UINTN Count
+# );
+#------------------------------------------------------------------------------
_InternalMemCopyMem:
push %esi
push %edi
- movl 16(%esp),%esi # esi <- Source
- movl 12(%esp),%edi # edi <- Destination
- movl 20(%esp),%edx # edx <- Count
- leal -1(%edi,%edx),%eax # eax <- End of Destination
- cmpl %edi,%esi
+ movl 16(%esp), %esi # esi <- Source
+ movl 12(%esp), %edi # edi <- Destination
+ movl 20(%esp), %edx # edx <- Count
+ leal -1(%esi, %edx), %eax # eax <- End of Source
+ cmpl %edi, %esi
jae L0
- cmpl %esi,%eax
+ cmpl %edi, %eax
jae @CopyBackward # Copy backward if overlapped
-L0:
- movl %edx,%ecx
- andl $3,%edx
- shrl $2,%ecx
+L0:
+ movl %edx, %ecx
+ andl $3, %edx
+ shrl $2, %ecx
rep
movsl # Copy as many Dwords as possible
jmp @CopyBytes
-@CopyBackward:
- movl %eax,%edi # edi <- End of Destination
- leal -1(%esi,%edx),%esi # esi <- End of Source
+@CopyBackward:
+ movl %eax, %esi # esi <- End of Source
+ leal -1(%edi, %edx), %edi # edi <- End of Destination
std
-@CopyBytes:
- movl %edx,%ecx
+@CopyBytes:
+ movl %edx, %ecx
rep
movsb # Copy bytes backward
cld
- movl 12(%esp),%eax # eax <- Destination as return value
+ movl 12(%esp), %eax # eax <- Destination as return value
pop %edi
pop %esi
ret
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm
index 7b3e5eafee..86677ef614 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm
@@ -25,14 +25,22 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemCopyMem (
+; IN VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; )
+;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES esi edi
mov esi, [esp + 16] ; esi <- Source
mov edi, [esp + 12] ; edi <- Destination
mov edx, [esp + 20] ; edx <- Count
- lea eax, [edi + edx - 1] ; eax <- End of Destination
+ lea eax, [esi + edx - 1] ; eax <- End of Source
cmp esi, edi
jae @F
- cmp eax, esi
+ cmp eax, edi
jae @CopyBackward ; Copy backward if overlapped
@@:
mov ecx, edx
@@ -41,8 +49,8 @@ InternalMemCopyMem PROC USES esi edi
rep movsd ; Copy as many Dwords as possible
jmp @CopyBytes
@CopyBackward:
- mov edi, eax ; edi <- End of Destination
- lea esi, [esi + edx - 1] ; esi <- End of Source
+ mov esi, eax ; esi <- End of Source
+ lea edi, [edi + edx - 1] ; edi <- End of Destination
std
@CopyBytes:
mov ecx, edx
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S
index ec1095a5fb..1e83064573 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S
@@ -27,17 +27,24 @@
#
#------------------------------------------------------------------------------
- .686:
- .code:
-
.global _InternalMemScanMem16
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem16 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT16 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem16:
push %edi
- movl 12(%esp),%ecx
- movl 8(%esp),%edi
- movl 16(%esp),%eax
+ movl 12(%esp), %ecx
+ movl 8(%esp), %edi
+ movl 16(%esp), %eax
repne scasw
- leal -2(%edi),%eax
+ leal -2(%edi), %eax
cmovnz %ecx, %eax
pop %edi
ret
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm
index 7071942ede..57fab61b77 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem16 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S
index b51b4fecdf..b7b93d9c0c 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S
@@ -27,17 +27,24 @@
#
#------------------------------------------------------------------------------
- .686:
- .code:
-
.global _InternalMemScanMem32
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem32 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT32 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem32:
push %edi
- movl 12(%esp),%ecx
- movl 8(%esp),%edi
- movl 16(%esp),%eax
+ movl 12(%esp), %ecx
+ movl 8(%esp), %edi
+ movl 16(%esp), %eax
repne scasl
- leal -4(%edi),%eax
+ leal -4(%edi), %eax
cmovnz %ecx, %eax
pop %edi
ret
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm
index e6aaf02bc3..6ac857ce16 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem32 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S
index 49e9e07cf7..6bbb18a334 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S
@@ -27,27 +27,33 @@
#
#------------------------------------------------------------------------------
- .686:
- .code:
-
.global _InternalMemScanMem64
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem64 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT64 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem64:
push %edi
- movl 12(%esp),%ecx
- movl 16(%esp),%eax
- movl 20(%esp),%edx
- movl 8(%esp),%edi
+ movl 12(%esp), %ecx
+ movl 16(%esp), %eax
+ movl 20(%esp), %edx
+ movl 8(%esp), %edi
L0:
- cmpl (%edi),%eax
- leal 8(%edi),%edi
+ cmpl (%edi), %eax
+ leal 8(%edi), %edi
loopne L0
jne L1
- cmpl -4(%edi),%edx
+ cmpl -4(%edi), %edx
jecxz L1
jne L0
L1:
- leal -8(%edi),%eax
+ leal -8(%edi), %eax
cmovne %ecx, %eax
pop %edi
ret
-
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm
index f9725a4a5d..ca54f13738 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem64 PROC USES edi
mov ecx, [esp + 12]
mov eax, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S
index da40c149e9..fe678fac26 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S
@@ -27,17 +27,24 @@
#
#------------------------------------------------------------------------------
- .686:
- .code:
-
.global _InternalMemScanMem8
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem8 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT8 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem8:
push %edi
- movl 12(%esp),%ecx
- movl 8(%esp),%edi
- movb 16(%esp),%al
+ movl 12(%esp), %ecx
+ movl 8(%esp), %edi
+ movb 16(%esp), %al
repne scasb
- leal -1(%edi),%eax
+ leal -1(%edi), %eax
cmovnz %ecx, %eax
pop %edi
ret
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm
index 6ae1900189..a3f65b64fa 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem8 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S
index 1e59587317..9dbfa284c0 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S
@@ -21,10 +21,19 @@
#
#------------------------------------------------------------------------------
- .386:
- .code:
+ .386:
+ .code:
.global _InternalMemSetMem
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT8 Value
+# )
+#------------------------------------------------------------------------------
_InternalMemSetMem:
push %edi
movl 16(%esp),%eax
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm
index 495dd3f4ba..98b1ed84c2 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm
@@ -25,6 +25,14 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT8 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem PROC USES edi
mov eax, [esp + 16]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S
index 3871c5c183..23860092af 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S
@@ -21,17 +21,23 @@
#
#------------------------------------------------------------------------------
- .386:
- .code:
-
.global _InternalMemSetMem16
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem16 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT16 Value
+# )
+#------------------------------------------------------------------------------
_InternalMemSetMem16:
push %edi
- movl 16(%esp),%eax
- movl 8(%esp),%edi
- movl 12(%esp),%ecx
+ movl 16(%esp), %eax
+ movl 8(%esp), %edi
+ movl 12(%esp), %ecx
rep
stosw
- movl 8(%esp),%eax
+ movl 8(%esp), %eax
pop %edi
ret
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm
index 483e26e2b6..7f4a8955f9 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm
@@ -25,6 +25,14 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem16 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT16 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem16 PROC USES edi
mov eax, [esp + 16]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S
index d7dd928c85..c11214f6d6 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S
@@ -21,10 +21,16 @@
#
#------------------------------------------------------------------------------
- .386:
- .code:
-
.global _InternalMemSetMem32
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem32 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT32 Value
+# )
+#------------------------------------------------------------------------------
_InternalMemSetMem32:
push %edi
movl 16(%esp),%eax
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm
index 18b77ce183..5876f4a741 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm
@@ -25,6 +25,14 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem32 PROC USES edi
mov eax, [esp + 16]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S
index 5172c306b1..c76bbae020 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S
@@ -21,20 +21,25 @@
#
#------------------------------------------------------------------------------
- .386:
- #.MODEL flat,C
- .code:
-
.global _InternalMemSetMem64
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemSetMem64 (
+# IN VOID *Buffer,
+# IN UINTN Count,
+# IN UINT64 Value
+# )
+#------------------------------------------------------------------------------
_InternalMemSetMem64:
push %edi
movl 12(%esp), %ecx
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 8(%esp), %edi
-L0:
- mov %eax,-8(%edi,%ecx,8)
- mov %edx,-4(%edi,%ecx,8)
+L0:
+ mov %eax, -8(%edi, %ecx, 8)
+ mov %edx, -4(%edi, %ecx, 8)
loop L0
movl %edi, %eax
pop %edi
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm
index 4679a384c6..687c18f312 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm
@@ -25,6 +25,14 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem64 PROC USES edi
mov ecx, [esp + 12]
mov eax, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S
index c3165bdc7e..7a01471ebb 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S
@@ -21,10 +21,15 @@
#
#------------------------------------------------------------------------------
- .386:
- .code:
-
.global _InternalMemZeroMem
+
+#------------------------------------------------------------------------------
+# VOID *
+# InternalMemZeroMem (
+# IN VOID *Buffer,
+# IN UINTN Count
+# );
+#------------------------------------------------------------------------------
_InternalMemZeroMem:
push %edi
xorl %eax,%eax
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm
index f892250d16..b3b8b5d1f1 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm
@@ -25,6 +25,13 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
InternalMemZeroMem PROC USES edi
xor eax, eax
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c
index 08247681c5..e2ffb5c3c2 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c
+++ b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c
@@ -30,7 +30,7 @@
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with zeros.
@param Length Number of bytes in Buffer to fill with zeros.
@@ -47,5 +47,5 @@ ZeroMem (
{
ASSERT (!(Buffer == NULL && Length > 0));
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
- return InternalMemSetMem (Buffer, Length, 0);
+ return InternalMemZeroMem (Buffer, Length);
}
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm
index b8e289bb27..554bc07c64 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCompareMem PROC USES rsi rdi
mov rsi, rcx
mov rdi, rdx
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm
index 43630715cb..a2e04056fd 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm
@@ -23,10 +23,19 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemCopyMem (
+; IN VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; )
+;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES rsi rdi
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
- lea r9, [rdi + r8 - 1] ; r9 <- End of Destination
+ lea r9, [rsi + r8 - 1] ; r9 <- End of Source
cmp rsi, rdi
mov rax, rdi ; rax <- Destination as return value
jae @F
@@ -39,8 +48,8 @@ InternalMemCopyMem PROC USES rsi rdi
rep movsq ; Copy as many Qwords as possible
jmp @CopyBytes
@CopyBackward:
- mov rdi, r9 ; rdi <- End of Destination
- lea rsi, [rsi + r8 - 1] ; esi <- End of Source
+ mov rsi, r9 ; rsi <- End of Source
+ lea rdi, [rdi + r8 - 1] ; esi <- End of Destination
std ; set direction flag
@CopyBytes:
mov rcx, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm
index 6af88fae5b..a2538c2cca 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem16 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm
index f9c9feb00e..e0523d8547 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem32 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm
index 2f286c9e2f..0e7e9c782f 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem64 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm
index 4027ece768..879273f960 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem8 PROC USES rdi
mov rdi, rcx
mov rcx, rdx
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm
index b9108c750e..5306520169 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm
@@ -23,6 +23,15 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT8 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem PROC USES rdi
mov rax, r8
mov rdi, rcx
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm
index 3a9fd47fc3..fce9ed7ed5 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm
@@ -23,6 +23,15 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem16 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT16 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem16 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm
index 2020d19065..ce9e54da85 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm
@@ -23,6 +23,15 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemSetMem32 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm
index 70ca4fb75a..97884a36fe 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm
@@ -23,6 +23,14 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
InternalMemSetMem64 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm
index c18a2e27c1..c01af8e6e4 100644
--- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm
+++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm
@@ -23,6 +23,13 @@
.code
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
InternalMemZeroMem PROC USES rdi
push rcx
xor rax, rax
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.S
index 428bb6a51b..7901b82a44 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemCompareMem
+
+#------------------------------------------------------------------------------
+# INTN
+# EFIAPI
+# InternalMemCompareMem (
+# IN CONST VOID *DestinationBuffer,
+# IN CONST VOID *SourceBuffer,
+# IN UINTN Length
+# );
+#------------------------------------------------------------------------------
_InternalMemCompareMem:
push %esi
push %edi
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.asm
index 3cf6fe7f73..1d0e7fad39 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CompareMem.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCompareMem PROC USES esi edi
mov esi, [esp + 12]
mov edi, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.S
index deb9860339..9ef9286051 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.S
@@ -21,32 +21,29 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemCopyMem
#------------------------------------------------------------------------------
# VOID *
-# _mem_CopyMem (
+# EFIAPI
+# InternalMemCopyMem (
# IN VOID *Destination,
# IN VOID *Source,
# IN UINTN Count
-# )
+# );
#------------------------------------------------------------------------------
-.global _InternalMemCopyMem
_InternalMemCopyMem:
push %esi
push %edi
movl 16(%esp), %esi # esi <- Source
movl 12(%esp), %edi # edi <- Destination
movl 20(%esp), %edx # edx <- Count
- leal -1(%edi,%edx,), %eax # eax <- End of Destination
+ leal -1(%esi,%edx,), %eax # eax <- End of Source
cmpl %edi, %esi
jae L0
- cmpl %esi, %eax # Overlapped?
+ cmpl %edi, %eax # Overlapped?
jae @CopyBackward # Copy backward if overlapped
-L0:
+L0:
xorl %ecx, %ecx
subl %edi, %ecx
andl $15, %ecx # ecx + edi aligns on 16-byte boundary
@@ -56,16 +53,16 @@ L0:
subl %ecx, %edx # edx <- remaining bytes to copy
rep
movsb
-L1:
+L1:
movl %edx, %ecx
andl $15, %edx
shrl $4, %ecx # ecx <- # of DQwords to copy
jz @CopyBytes
addl $-16, %esp
movdqu %xmm0, (%esp)
-L2:
+L2:
movdqu (%esi), %xmm0
- movntdq %xmm0, (%edi)
+ movntdq %xmm0, (%edi)
addl $16, %esi
addl $16, %edi
loop L2
@@ -73,11 +70,11 @@ L2:
movdqu (%esp),%xmm0
addl $16, %esp # stack cleanup
jmp @CopyBytes
-@CopyBackward:
- movl %eax, %edi # edi <- Last byte in Destination
- leal -1(%esi,%edx,), %esi # esi <- Last byte in Source
+@CopyBackward:
+ movl %eax, %esi # esi <- Last byte in Source
+ leal -1(%edi,%edx,), %edi # edi <- Last byte in Destination
std
-@CopyBytes:
+@CopyBytes:
movl %edx, %ecx
rep
movsb
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.asm
index 6127cc2188..77fb786d98 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.asm
@@ -28,20 +28,20 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_CopyMem (
+; InternalMemCopyMem (
; IN VOID *Destination,
; IN VOID *Source,
; IN UINTN Count
-; )
+; );
;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES esi edi
mov esi, [esp + 16] ; esi <- Source
mov edi, [esp + 12] ; edi <- Destination
mov edx, [esp + 20] ; edx <- Count
- lea eax, [edi + edx - 1] ; eax <- End of Destination
+ lea eax, [esi + edx - 1] ; eax <- End of Source
cmp esi, edi
jae @F
- cmp eax, esi ; Overlapped?
+ cmp eax, edi ; Overlapped?
jae @CopyBackward ; Copy backward if overlapped
@@:
xor ecx, ecx
@@ -70,8 +70,8 @@ InternalMemCopyMem PROC USES esi edi
add esp, 16 ; stack cleanup
jmp @CopyBytes
@CopyBackward:
- mov edi, eax ; edi <- Last byte in Destination
- lea esi, [esi + edx - 1] ; esi <- Last byte in Source
+ mov esi, eax ; esi <- Last byte in Source
+ lea edi, [edi + edx - 1] ; edi <- Last byte in Destination
std
@CopyBytes:
mov ecx, edx
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.S
index c433a28b72..1e83064573 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem16
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem16 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT16 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem16:
push %edi
movl 12(%esp), %ecx
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.asm
index 7071942ede..57fab61b77 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem16.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem16 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.S
index 1de283c788..b7b93d9c0c 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.S
@@ -27,17 +27,23 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem32
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem32 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT32 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem32:
push %edi
movl 12(%esp), %ecx
movl 8(%esp), %edi
movl 16(%esp), %eax
- repnz scasl
+ repne scasl
leal -4(%edi), %eax
cmovnz %ecx, %eax
pop %edi
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.asm
index e6aaf02bc3..6ac857ce16 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem32.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem32 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.S
index 00f6d74436..6bbb18a334 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.S
@@ -27,18 +27,24 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem64
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem64 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT64 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem64:
push %edi
movl 12(%esp), %ecx
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 8(%esp), %edi
-L0:
+L0:
cmpl (%edi), %eax
leal 8(%edi), %edi
loopne L0
@@ -46,7 +52,7 @@ L0:
cmpl -4(%edi), %edx
jecxz L1
jne L0
-L1:
+L1:
leal -8(%edi), %eax
cmovne %ecx, %eax
pop %edi
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.asm
index f9725a4a5d..ca54f13738 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem64.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem64 PROC USES edi
mov ecx, [esp + 12]
mov eax, [esp + 16]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.S
index 57640378b4..fe678fac26 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.S
@@ -27,11 +27,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .code:
-
.global _InternalMemScanMem8
+
+#------------------------------------------------------------------------------
+# CONST VOID *
+# EFIAPI
+# InternalMemScanMem8 (
+# IN CONST VOID *Buffer,
+# IN UINTN Length,
+# IN UINT8 Value
+# );
+#------------------------------------------------------------------------------
_InternalMemScanMem8:
push %edi
movl 12(%esp), %ecx
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.asm
index 6ae1900189..a3f65b64fa 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ScanMem8.asm
@@ -31,6 +31,15 @@
.model flat,C
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem8 PROC USES edi
mov ecx, [esp + 12]
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.S
index e778cd8b86..d73ebfb710 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.S
@@ -21,10 +21,10 @@
#
#------------------------------------------------------------------------------
- .686:
+ .686:
#.MODEL flat,C
- .xmm:
- .code:
+ .xmm:
+ .code:
#------------------------------------------------------------------------------
# VOID *
@@ -32,7 +32,7 @@
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT8 Value
-# )
+# );
#------------------------------------------------------------------------------
.global _InternalMemSetMem
_InternalMemSetMem:
@@ -49,7 +49,7 @@ _InternalMemSetMem:
subl %ecx, %edx
rep
stosb
-L0:
+L0:
movl %edx, %ecx
andl $15, %edx
shrl $4, %ecx # ecx <- # of DQwords to set
@@ -60,14 +60,14 @@ L0:
movd %eax, %xmm0
pshuflw $0, %xmm0, %xmm0
movlhps %xmm0, %xmm0
-L1:
+L1:
movntdq %xmm0, (%edi)
addl $16, %edi
loop L1
mfence
movdqu (%esp), %xmm0
addl $16, %esp # stack cleanup
-@SetBytes:
+@SetBytes:
movl %edx, %ecx
rep
stosb
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.asm
index 62b10cff0a..a4de29c521 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.asm
@@ -28,11 +28,12 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem (
+; EFIAPI
+; InternalMemSetMem (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT8 Value
-; )
+; );
;------------------------------------------------------------------------------
InternalMemSetMem PROC USES edi
mov edx, [esp + 12] ; edx <- Count
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.S
index 27110b32d3..21e3935b99 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.S
@@ -21,20 +21,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemSetMem16
#------------------------------------------------------------------------------
# VOID *
-# _mem_SetMem16 (
+# EFIAPI
+# InternalMemSetMem16 (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT16 Value
# )
#------------------------------------------------------------------------------
-.global _InternalMemSetMem16
_InternalMemSetMem16:
push %edi
movl 12(%esp), %edx
@@ -50,7 +47,7 @@ _InternalMemSetMem16:
subl %ecx, %edx
rep
stosw
-L0:
+L0:
movl %edx, %ecx
andl $7, %edx
shrl $3, %ecx
@@ -63,7 +60,7 @@ L1:
addl $16, %edi
loop L1
mfence
-@SetWords:
+@SetWords:
movl %edx, %ecx
rep
stosw
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.asm
index 3fabb00d31..a709899fe2 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem16.asm
@@ -28,11 +28,12 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem16 (
+; EFIAPI
+; InternalMemSetMem16 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT16 Value
-; )
+; );
;------------------------------------------------------------------------------
InternalMemSetMem16 PROC USES edi
mov edx, [esp + 12]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.S
index a1a6317115..b6823ad125 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.S
@@ -21,20 +21,17 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemSetMem32
#------------------------------------------------------------------------------
# VOID *
-# _mem_SetMem32 (
+# EFIAPI
+# InternalMemSetMem32 (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT32 Value
-# )
+# );
#------------------------------------------------------------------------------
-.global _InternalMemSetMem32
_InternalMemSetMem32:
push %edi
movl 12(%esp), %edx
@@ -50,19 +47,19 @@ _InternalMemSetMem32:
subl %ecx, %edx
rep
stosl
-L0:
+L0:
movl %edx, %ecx
andl $3, %edx
shrl $2, %ecx
jz @SetDwords
movd %eax, %xmm0
pshufd $0, %xmm0, %xmm0
-L1:
+L1:
movntdq %xmm0, (%edi)
addl $16, %edi
loop L1
mfence
-@SetDwords:
+@SetDwords:
movl %edx, %ecx
rep
stosl
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.asm
index a7f1f0e127..99954a5e4b 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem32.asm
@@ -28,11 +28,12 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem32 (
+; EFIAPI
+; InternalMemSetMem32 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT32 Value
-; )
+; );
;------------------------------------------------------------------------------
InternalMemSetMem32 PROC USES edi
mov edx, [esp + 12]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.S
index fa60007f5a..1f9e2f63a3 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.S
@@ -21,15 +21,17 @@
#
#------------------------------------------------------------------------------
+.globl _InternalMemSetMem64
+
#------------------------------------------------------------------------------
# VOID *
+# EFIAPI
# InternalMemSetMem64 (
# IN VOID *Buffer,
# IN UINTN Count,
# IN UINT64 Value
-# )
+# );
#------------------------------------------------------------------------------
-.globl _InternalMemSetMem64
_InternalMemSetMem64:
movl 4(%esp), %eax
movl 8(%esp), %ecx
@@ -40,20 +42,17 @@ _InternalMemSetMem64:
movq %xmm0, (%edx)
addl $8, %edx
decl %ecx
-L1:
+L1:
shrl %ecx
jz @SetQwords
movlhps %xmm0, %xmm0
-L2:
+L2:
movntdq %xmm0, (%edx)
leal 16(%edx), %edx
loop L2
mfence
-@SetQwords:
+@SetQwords:
jnc L3
movq %xmm0, (%edx)
-L3:
+L3:
ret
-
-
-
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.asm
index c5d75c6f2b..69406707a6 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem64.asm
@@ -28,6 +28,7 @@
;------------------------------------------------------------------------------
; VOID *
+; EFIAPI
; InternalMemSetMem64 (
; IN VOID *Buffer,
; IN UINTN Count,
@@ -35,8 +36,8 @@
; )
;------------------------------------------------------------------------------
InternalMemSetMem64 PROC
- mov eax, [esp + 4]
- mov ecx, [esp + 8]
+ mov eax, [esp + 4] ; eax <- Buffer
+ mov ecx, [esp + 8] ; ecx <- Count
test al, 8
mov edx, eax
movq xmm0, [esp + 12]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.S b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.S
index f927f9128f..f57276091f 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.S
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.S
@@ -21,19 +21,16 @@
#
#------------------------------------------------------------------------------
- .686:
- #.MODEL flat,C
- .xmm:
- .code:
+.global _InternalMemZeroMem
#------------------------------------------------------------------------------
# VOID *
-# _mem_ZeroMem (
+# EFIAPI
+# InternalMemZeroMem (
# IN VOID *Buffer,
# IN UINTN Count
-# )
+# );
#------------------------------------------------------------------------------
-.global _InternalMemZeroMem
_InternalMemZeroMem:
push %edi
movl 8(%esp), %edi
@@ -48,18 +45,18 @@ _InternalMemZeroMem:
subl %ecx, %edx
rep
stosb
-L0:
+L0:
movl %edx, %ecx
andl $15, %edx
shrl $4, %ecx
jz @ZeroBytes
pxor %xmm0, %xmm0
-L1:
+L1:
movntdq %xmm0, (%edi)
addl $16, %edi
loop L1
mfence
-@ZeroBytes:
+@ZeroBytes:
movl %edx, %ecx
rep
stosb
diff --git a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.asm
index b532382e2e..3792c88879 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/Ia32/ZeroMem.asm
@@ -28,10 +28,11 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_ZeroMem (
+; EFIAPI
+; InternalMemZeroMem (
; IN VOID *Buffer,
; IN UINTN Count
-; )
+; );
;------------------------------------------------------------------------------
InternalMemZeroMem PROC USES edi
mov edi, [esp + 8]
diff --git a/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c
index 08247681c5..e2ffb5c3c2 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c
+++ b/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c
@@ -30,7 +30,7 @@
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with zeros.
@param Length Number of bytes in Buffer to fill with zeros.
@@ -47,5 +47,5 @@ ZeroMem (
{
ASSERT (!(Buffer == NULL && Length > 0));
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
- return InternalMemSetMem (Buffer, Length, 0);
+ return InternalMemZeroMem (Buffer, Length);
}
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/CompareMem.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/CompareMem.asm
index b8e289bb27..554bc07c64 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/CompareMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/CompareMem.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
InternalMemCompareMem PROC USES rsi rdi
mov rsi, rcx
mov rdi, rdx
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/CopyMem.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/CopyMem.asm
index 955cd25f36..03ffe0c00f 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/CopyMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/CopyMem.asm
@@ -25,20 +25,21 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_CopyMem (
+; EFIAPI
+; InternalMemCopyMem (
; IN VOID *Destination,
; IN VOID *Source,
; IN UINTN Count
-; )
+; );
;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES rsi rdi
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
- lea r9, [rdi + r8 - 1] ; r9 <- Last byte of Destination
+ lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source
cmp rsi, rdi
mov rax, rdi ; rax <- Destination as return value
jae @F ; Copy forward if Source > Destination
- cmp r9, rsi ; Overlapped?
+ cmp r9, rdi ; Overlapped?
jae @CopyBackward ; Copy backward if overlapped
@@:
xor rcx, rcx
@@ -65,8 +66,8 @@ InternalMemCopyMem PROC USES rsi rdi
movdqa xmm0, [rsp + 18h] ; restore xmm0
jmp @CopyBytes ; copy remaining bytes
@CopyBackward:
- mov rdi, r9 ; rdi <- Last byte of Destination
- lea rsi, [rsi + r8 - 1] ; rsi <- Last byte of Source
+ mov rsi, r9 ; rsi <- Last byte of Source
+ lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination
std
@CopyBytes:
mov rcx, r8
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem16.asm
index 6af88fae5b..a2538c2cca 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem16.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem16 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem32.asm
index f9c9feb00e..e0523d8547 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem32.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem32 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem64.asm
index 2f286c9e2f..0e7e9c782f 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem64.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem64 PROC USES rdi
mov rdi, rcx
mov rax, r8
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem8.asm
index 4027ece768..879273f960 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem8.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/ScanMem8.asm
@@ -29,6 +29,15 @@
.code
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
InternalMemScanMem8 PROC USES rdi
mov rdi, rcx
mov rcx, rdx
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem.asm
index 2aba207ab9..25cfcf0d12 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem.asm
@@ -25,7 +25,7 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem (
+; InternalMemSetMem (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT8 Value
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem16.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem16.asm
index a2f4d0e538..77b8cf43aa 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem16.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem16.asm
@@ -25,7 +25,7 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem16 (
+; InternalMemSetMem16 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT16 Value
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem32.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem32.asm
index 24207ec699..eba29bb88d 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem32.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem32.asm
@@ -25,7 +25,7 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_SetMem32 (
+; InternalMemSetMem32 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT8 Value
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem64.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem64.asm
index ef94c562b5..a26b9412d4 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem64.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/SetMem64.asm
@@ -32,9 +32,10 @@
; )
;------------------------------------------------------------------------------
InternalMemSetMem64 PROC
- mov rax, rcx
+ mov rax, rcx ; rax <- Buffer
+ xchg rcx, rdx ; rcx <- Count & rdx <- Buffer
test dl, 8
- xchg rcx, rdx
+ movd xmm0, r8
jz @F
mov [rdx], r8
add rdx, 8
@@ -42,7 +43,6 @@ InternalMemSetMem64 PROC
@@:
shr rcx, 1
jz @SetQwords
- movd xmm0, r8
movlhps xmm0, xmm0
@@:
movntdq [rdx], xmm0
diff --git a/MdePkg/Library/BaseMemoryLibSse2/x64/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibSse2/x64/ZeroMem.asm
index 6d0f99ba94..7eebd3a8ef 100644
--- a/MdePkg/Library/BaseMemoryLibSse2/x64/ZeroMem.asm
+++ b/MdePkg/Library/BaseMemoryLibSse2/x64/ZeroMem.asm
@@ -25,7 +25,7 @@
;------------------------------------------------------------------------------
; VOID *
-; _mem_ZeroMem (
+; InternalMemZeroMem (
; IN VOID *Buffer,
; IN UINTN Count
; )
diff --git a/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c
index 08247681c5..e2ffb5c3c2 100644
--- a/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c
+++ b/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c
@@ -30,7 +30,7 @@
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with zeros.
@param Length Number of bytes in Buffer to fill with zeros.
@@ -47,5 +47,5 @@ ZeroMem (
{
ASSERT (!(Buffer == NULL && Length > 0));
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
- return InternalMemSetMem (Buffer, Length, 0);
+ return InternalMemZeroMem (Buffer, Length);
}
diff --git a/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c
index 08247681c5..e2ffb5c3c2 100644
--- a/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c
+++ b/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c
@@ -30,7 +30,7 @@
This function fills Length bytes of Buffer with zeros, and returns Buffer.
If Length > 0 and Buffer is NULL, then ASSERT().
- If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT().
@param Buffer Pointer to the target buffer to fill with zeros.
@param Length Number of bytes in Buffer to fill with zeros.
@@ -47,5 +47,5 @@ ZeroMem (
{
ASSERT (!(Buffer == NULL && Length > 0));
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
- return InternalMemSetMem (Buffer, Length, 0);
+ return InternalMemZeroMem (Buffer, Length);
}