mirror of https://github.com/acidanthera/audk.git
sync comments.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6274 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
85ea851e6a
commit
57246fe073
|
@ -38,15 +38,15 @@ ASM_PFX(InternalX86DisablePaging32):
|
|||
movl 8(%esp), %ecx
|
||||
movl 12(%esp), %edx
|
||||
pushfl
|
||||
pop %edi
|
||||
pop %edi # save EFLAGS to edi
|
||||
cli
|
||||
movl %cr0, %eax
|
||||
btrl $31, %eax
|
||||
movl 16(%esp), %esp
|
||||
movl %eax, %cr0
|
||||
push %edi
|
||||
popfl
|
||||
popfl # restore EFLAGS from edi
|
||||
push %edx
|
||||
push %ecx
|
||||
call *%ebx
|
||||
jmp .
|
||||
jmp . # EntryPoint() should not return
|
||||
|
|
|
@ -34,8 +34,8 @@ ASM_PFX(InternalMathDivU64x32):
|
|||
movl 12(%esp), %ecx
|
||||
xorl %edx, %edx
|
||||
divl %ecx
|
||||
push %eax
|
||||
push %eax # save quotient on stack
|
||||
movl 8(%esp), %eax
|
||||
divl %ecx
|
||||
pop %edx
|
||||
pop %edx # restore high-order dword of the quotient
|
||||
ret
|
||||
|
|
|
@ -31,16 +31,16 @@
|
|||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalMathDivRemU64x32):
|
||||
movl 12(%esp), %ecx
|
||||
movl 8(%esp), %eax
|
||||
movl 12(%esp), %ecx # ecx <- divisor
|
||||
movl 8(%esp), %eax # eax <- dividend[32..63]
|
||||
xorl %edx, %edx
|
||||
divl %ecx
|
||||
divl %ecx # eax <- quotient[32..63], edx <- remainder
|
||||
push %eax
|
||||
movl 8(%esp), %eax
|
||||
divl %ecx
|
||||
movl 20(%esp), %ecx
|
||||
jecxz L1
|
||||
movl 8(%esp), %eax # eax <- dividend[0..31]
|
||||
divl %ecx # eax <- quotient[0..31]
|
||||
movl 20(%esp), %ecx # ecx <- Remainder
|
||||
jecxz L1 # abandon remainder if Remainder == NULL
|
||||
movl %edx, (%ecx)
|
||||
L1:
|
||||
pop %edx
|
||||
pop %edx # edx <- quotient[32..63]
|
||||
ret
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalMathDivRemU64x64):
|
||||
movl 16(%esp), %ecx
|
||||
movl 16(%esp), %ecx # ecx <- divisor[32..63]
|
||||
testl %ecx, %ecx
|
||||
jnz Hard
|
||||
jnz Hard # call _@DivRemU64x64 if Divisor > 2^32
|
||||
movl 20(%esp), %ecx
|
||||
jecxz L1
|
||||
and $0, 4(%ecx)
|
||||
movl %ecx, 16(%esp)
|
||||
and $0, 4(%ecx) # zero high dword of remainder
|
||||
movl %ecx, 16(%esp) # set up stack frame to match DivRemU64x32
|
||||
L1:
|
||||
jmp ASM_PFX(InternalMathDivRemU64x32)
|
||||
Hard:
|
||||
|
@ -46,10 +46,10 @@ Hard:
|
|||
push %esi
|
||||
push %edi
|
||||
mov 20(%esp), %edx
|
||||
mov 16(%esp), %eax
|
||||
mov 16(%esp), %eax # edx:eax <- dividend
|
||||
movl %edx, %edi
|
||||
movl %eax, %esi
|
||||
mov 24(%esp), %ebx
|
||||
movl %eax, %esi # edi:esi <- dividend
|
||||
mov 24(%esp), %ebx # ecx:ebx <- divisor
|
||||
L2:
|
||||
shrl %edx
|
||||
rcrl $1, %eax
|
||||
|
@ -57,32 +57,32 @@ L2:
|
|||
shrl %ecx
|
||||
jnz L2
|
||||
divl %ebx
|
||||
movl %eax, %ebx
|
||||
movl 28(%esp), %ecx
|
||||
mull 24(%esp)
|
||||
imull %ebx, %ecx
|
||||
addl %ecx, %edx
|
||||
mov 32(%esp), %ecx
|
||||
jc TooLarge
|
||||
cmpl %edx, %edi
|
||||
movl %eax, %ebx # ebx <- quotient
|
||||
movl 28(%esp), %ecx # ecx <- high dword of divisor
|
||||
mull 24(%esp) # edx:eax <- quotient * divisor[0..31]
|
||||
imull %ebx, %ecx # ecx <- quotient * divisor[32..63]
|
||||
addl %ecx, %edx # edx <- (quotient * divisor)[32..63]
|
||||
mov 32(%esp), %ecx # ecx <- addr for Remainder
|
||||
jc TooLarge # product > 2^64
|
||||
cmpl %edx, %edi # compare high 32 bits
|
||||
ja Correct
|
||||
jb TooLarge
|
||||
jb TooLarge # product > dividend
|
||||
cmpl %eax, %esi
|
||||
jae Correct
|
||||
jae Correct # product <= dividend
|
||||
TooLarge:
|
||||
decl %ebx
|
||||
jecxz Return
|
||||
decl %ebx # adjust quotient by -1
|
||||
jecxz Return # return if Remainder == NULL
|
||||
sub 24(%esp), %eax
|
||||
sbb 28(%esp), %edx
|
||||
sbb 28(%esp), %edx # edx:eax <- (quotient - 1) * divisor
|
||||
Correct:
|
||||
jecxz Return
|
||||
subl %eax, %esi
|
||||
sbbl %edx, %edi
|
||||
sbbl %edx, %edi # edi:esi <- remainder
|
||||
movl %esi, (%ecx)
|
||||
movl %edi, 4(%ecx)
|
||||
Return:
|
||||
movl %ebx, %eax
|
||||
xorl %edx, %edx
|
||||
movl %ebx, %eax # eax <- quotient
|
||||
xorl %edx, %edx # quotient is 32 bits long
|
||||
pop %edi
|
||||
pop %esi
|
||||
pop %ebx
|
||||
|
|
|
@ -38,14 +38,14 @@ ASM_PFX(InternalX86EnablePaging32):
|
|||
movl 8(%esp), %ecx
|
||||
movl 12(%esp), %edx
|
||||
pushfl
|
||||
pop %edi
|
||||
pop %edi # save flags in edi
|
||||
cli
|
||||
movl %cr0, %eax
|
||||
btsl $31, %eax
|
||||
movl 16(%esp), %esp
|
||||
movl %eax, %cr0
|
||||
push %edi
|
||||
popfl
|
||||
popfl # restore flags
|
||||
push %edx
|
||||
push %ecx
|
||||
call *%ebx
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalX86EnablePaging64):
|
||||
cli
|
||||
movl $LongStart, (%esp)
|
||||
movl $LongStart, (%esp) # offset for far retf, seg is the 1st arg
|
||||
movl %cr4, %eax
|
||||
orb $0x20, %al
|
||||
movl %eax, %cr4 # enable PAE
|
||||
|
@ -45,11 +45,11 @@ ASM_PFX(InternalX86EnablePaging64):
|
|||
orb $1, %ah # set LME
|
||||
wrmsr
|
||||
movl %cr0, %eax
|
||||
btsl $31, %eax
|
||||
btsl $31, %eax # set PG
|
||||
movl %eax, %cr0 # enable paging
|
||||
lret
|
||||
lret # topmost 2 dwords hold the address
|
||||
LongStart: # long mode starts here
|
||||
.byte 0x67, 0x48
|
||||
.byte 0x67, 0x48 # 32-bit address size, 64-bit operand size
|
||||
movl (%esp), %ebx # mov rbx, [esp]
|
||||
.byte 0x67, 0x48
|
||||
movl 8(%esp), %ecx # mov rcx, [esp + 8]
|
||||
|
@ -60,4 +60,4 @@ LongStart: # long mode starts here
|
|||
.byte 0x48
|
||||
addl $0x-0x20, %esp # add rsp, -20h
|
||||
call *%ebx # call rbx
|
||||
jmp .
|
||||
jmp . # no one should get here
|
||||
|
|
|
@ -31,6 +31,6 @@
|
|||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalX86FxRestore):
|
||||
movl 4(%esp), %eax
|
||||
movl 4(%esp), %eax # Buffer must be 16-byte aligned
|
||||
fxrstor (%eax)
|
||||
ret
|
||||
|
|
|
@ -31,6 +31,6 @@
|
|||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalX86FxSave):
|
||||
movl 4(%esp), %eax
|
||||
movl 4(%esp), %eax # Buffer must be 16-byte aligned
|
||||
fxsave (%eax)
|
||||
ret
|
||||
|
|
|
@ -38,7 +38,7 @@ ASM_PFX(InternalMathLRotU64):
|
|||
shldl %cl, %eax, %edx
|
||||
rorl %cl, %ebx
|
||||
shldl %cl, %ebx, %eax
|
||||
testb $32, %cl
|
||||
testb $32, %cl # Count >= 32?
|
||||
cmovnz %eax, %ecx
|
||||
cmovnz %edx, %eax
|
||||
cmovnz %ecx, %edx
|
||||
|
|
|
@ -33,7 +33,7 @@ ASM_PFX(InternalMathLShiftU64):
|
|||
movb 12(%esp), %cl
|
||||
xorl %eax, %eax
|
||||
movl 4(%esp), %edx
|
||||
testb $32, %cl
|
||||
testb $32, %cl # Count >= 32?
|
||||
cmovz %edx, %eax
|
||||
cmovz 0x8(%esp), %edx
|
||||
shld %cl, %eax, %edx
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalLongJump):
|
||||
pop %eax
|
||||
pop %edx
|
||||
pop %eax
|
||||
pop %eax # skip return address
|
||||
pop %edx # edx <- JumpBuffer
|
||||
pop %eax # eax <- Value
|
||||
movl (%edx), %ebx
|
||||
movl 4(%edx), %esi
|
||||
movl 8(%edx), %edi
|
||||
movl 12(%edx), %ebp
|
||||
movl 16(%edx), %esp
|
||||
jmp *20(%edx)
|
||||
jmp *20(%edx) # restore "eip"
|
||||
|
|
|
@ -36,5 +36,5 @@ ASM_PFX(AsmMonitor):
|
|||
movl 4(%esp), %eax
|
||||
movl 8(%esp), %ecx
|
||||
movl 12(%esp), %edx
|
||||
monitor %eax, %ecx, %edx
|
||||
monitor %eax, %ecx, %edx # monitor
|
||||
ret
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
ASM_PFX(InternalMathMultU64x32):
|
||||
movl 12(%esp), %ecx
|
||||
movl %ecx, %eax
|
||||
imull 8(%esp), %ecx
|
||||
imull 8(%esp), %ecx # overflow not detectable
|
||||
mull 0x4(%esp)
|
||||
addl %ecx, %edx
|
||||
ret
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalMathMultU64x64):
|
||||
push %ebx
|
||||
movl 8(%esp), %ebx
|
||||
movl 16(%esp), %edx
|
||||
movl 8(%esp), %ebx # ebx <- M1[0..31]
|
||||
movl 16(%esp), %edx # edx <- M2[0..31]
|
||||
movl %ebx, %ecx
|
||||
movl %edx, %eax
|
||||
imull 20(%esp), %ebx
|
||||
imull 12(%esp), %edx
|
||||
addl %edx, %ebx
|
||||
mull %ecx
|
||||
addl %ebx, %edx
|
||||
imull 20(%esp), %ebx # ebx <- M1[0..31] * M2[32..63]
|
||||
imull 12(%esp), %edx # edx <- M1[32..63] * M2[0..31]
|
||||
addl %edx, %ebx # carries are abandoned
|
||||
mull %ecx # edx:eax <- M1[0..31] * M2[0..31]
|
||||
addl %ebx, %edx # carries are abandoned
|
||||
pop %ebx
|
||||
ret
|
||||
|
|
|
@ -34,5 +34,5 @@
|
|||
ASM_PFX(AsmMwait):
|
||||
movl 4(%esp), %eax
|
||||
movl 8(%esp), %ecx
|
||||
mwait %eax, %ecx
|
||||
mwait %eax, %ecx # mwait
|
||||
ret
|
||||
|
|
|
@ -38,8 +38,8 @@ ASM_PFX(InternalMathRRotU64):
|
|||
shrdl %cl, %edx, %eax
|
||||
roll %cl, %ebx
|
||||
shrdl %cl, %ebx, %edx
|
||||
testb $32, %cl
|
||||
cmovnz %eax, %ecx
|
||||
testb $32, %cl # Count >= 32?
|
||||
cmovnz %eax, %ecx # switch eax & edx if Count >= 32
|
||||
cmovnz %edx, %eax
|
||||
cmovnz %ecx, %edx
|
||||
pop %ebx
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(InternalMathRShiftU64):
|
||||
movb 12(%esp), %cl
|
||||
movb 12(%esp), %cl # cl <- Count
|
||||
xorl %edx, %edx
|
||||
movl 8(%esp), %eax
|
||||
testb $32, %cl
|
||||
testb $32, %cl # Count >= 32?
|
||||
cmovz %eax, %edx
|
||||
cmovz 0x4(%esp), %eax
|
||||
shrdl %cl, %edx, %eax
|
||||
|
|
|
@ -30,15 +30,15 @@
|
|||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(SetJump):
|
||||
pushl 0x4(%esp)
|
||||
call ASM_PFX(InternalAssertJumpBuffer)
|
||||
pop %ecx
|
||||
call ASM_PFX(InternalAssertJumpBuffer) # To validate JumpBuffer
|
||||
pop %ecx
|
||||
pop %ecx # ecx <- return address
|
||||
movl (%esp), %edx
|
||||
movl %ebx, (%edx)
|
||||
movl %esi, 4(%edx)
|
||||
movl %edi, 8(%edx)
|
||||
movl %ebp, 12(%edx)
|
||||
movl %esp, 16(%edx)
|
||||
movl %ecx, 20(%edx)
|
||||
movl %ecx, 20(%edx) # eip value to restore in LongJump
|
||||
xorl %eax, %eax
|
||||
jmp *%ecx
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#------------------------------------------------------------------------------
|
||||
.globl ASM_PFX(InternalMathSwapBytes64)
|
||||
ASM_PFX(InternalMathSwapBytes64):
|
||||
movl 8(%esp), %eax
|
||||
movl 4(%esp), %edx
|
||||
movl 8(%esp), %eax # eax <- upper 32 bits
|
||||
movl 4(%esp), %edx # edx <- lower 32 bits
|
||||
bswapl %eax
|
||||
bswapl %edx
|
||||
ret
|
||||
|
|
Loading…
Reference in New Issue