mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
1. Updated function headers for all assembly function
2. Optimized register usage in SetMemXX functions in all lib instances 3. Fixed a logical error in CopyMem for all lib instances git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1139 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
27169a56e6
commit
eb227e96bd
MdePkg/Library
BaseMemoryLib
BaseMemoryLibMmx
BaseMemoryLibMmx.msa
Ia32
CompareMem.SCompareMem.asmCopyMem.SCopyMem.asmScanMem16.SScanMem16.asmScanMem32.SScanMem32.asmScanMem64.SScanMem64.asmScanMem8.SScanMem8.asmSetMem.SSetMem.asmSetMem16.SSetMem16.asmSetMem32.SSetMem32.asmSetMem64.SSetMem64.asmZeroMem.SZeroMem.asm
X64
CompareMem.asmCopyMem.asmScanMem16.asmScanMem32.asmScanMem64.asmScanMem8.asmSetMem.asmSetMem16.asmSetMem32.asmSetMem64.asmZeroMem.asm
ZeroMemWrapper.cBaseMemoryLibRepStr
Ia32
CompareMem.SCompareMem.asmCopyMem.SCopyMem.asmScanMem16.SScanMem16.asmScanMem32.SScanMem32.asmScanMem64.SScanMem64.asmScanMem8.SScanMem8.asmSetMem.SSetMem.asmSetMem16.SSetMem16.asmSetMem32.SSetMem32.asmSetMem64.SSetMem64.asmZeroMem.SZeroMem.asm
ZeroMemWrapper.cx64
BaseMemoryLibSse2
@ -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);
|
||||
}
|
||||
|
@ -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"/>
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -23,35 +23,27 @@
|
||||
|
||||
.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
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
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
|
||||
movq %mm0, (%esp) # save mm0
|
||||
movd %eax, %mm0
|
||||
pshufw $0x0,%mm0,%mm0
|
||||
L0:
|
||||
movntq %mm0, (%edi)
|
||||
addl $8, %edi
|
||||
loop L0
|
||||
mfence
|
||||
movq (%esp), %mm0 # restore mm0
|
||||
popl %ecx # stack cleanup
|
||||
popl %ecx
|
||||
@SetBytes:
|
||||
andl $7, %edx
|
||||
shrl $3, %ecx # # of Qwords to set
|
||||
jz L1
|
||||
addl $0x-10, %esp
|
||||
movq %mm0, (%esp) # save mm0
|
||||
movq %mm1, 8(%esp) # save mm1
|
||||
movd %eax, %mm0
|
||||
movd %eax, %mm1
|
||||
psllq $32, %mm0
|
||||
por %mm1, %mm0 # fill mm0 with 8 Value's
|
||||
L0:
|
||||
movq %mm0, (%edi)
|
||||
addl $8, %edi
|
||||
loopl L0
|
||||
movq (%esp), %mm0 # restore mm0
|
||||
movq 8(%esp), %mm1 # restore mm1
|
||||
addl $0x10, %esp # stack cleanup
|
||||
L1:
|
||||
movl %edx, %ecx
|
||||
rep
|
||||
stosb
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
54
MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm
Normal file
54
MdePkg/Library/BaseMemoryLibMmx/X64/ZeroMem.asm
Normal file
@ -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
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -21,10 +21,15 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.386:
|
||||
.code:
|
||||
|
||||
.global _InternalMemZeroMem
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID *
|
||||
# InternalMemZeroMem (
|
||||
# IN VOID *Buffer,
|
||||
# IN UINTN Count
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
_InternalMemZeroMem:
|
||||
push %edi
|
||||
xorl %eax,%eax
|
||||
|
@ -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]
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -23,6 +23,13 @@
|
||||
|
||||
.code
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID *
|
||||
; InternalMemZeroMem (
|
||||
; IN VOID *Buffer,
|
||||
; IN UINTN Count
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalMemZeroMem PROC USES rdi
|
||||
push rcx
|
||||
xor rax, rax
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -28,10 +28,11 @@
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID *
|
||||
; _mem_ZeroMem (
|
||||
; EFIAPI
|
||||
; InternalMemZeroMem (
|
||||
; IN VOID *Buffer,
|
||||
; IN UINTN Count
|
||||
; )
|
||||
; );
|
||||
;------------------------------------------------------------------------------
|
||||
InternalMemZeroMem PROC USES edi
|
||||
mov edi, [esp + 8]
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID *
|
||||
; _mem_SetMem (
|
||||
; InternalMemSetMem (
|
||||
; IN VOID *Buffer,
|
||||
; IN UINTN Count,
|
||||
; IN UINT8 Value
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user