Move SmmDebug feature from ASM to C.
SmmDebug feature is implemented in ASM, which is not easy to maintain. So we move it to C function. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: "Kinney, Michael D" <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18946 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -24,7 +24,6 @@ ASM_GLOBAL ASM_PFX(gcSmiHandlerSize)
|
||||
ASM_GLOBAL ASM_PFX(gSmiCr3)
|
||||
ASM_GLOBAL ASM_PFX(gSmiStack)
|
||||
ASM_GLOBAL ASM_PFX(gSmbase)
|
||||
ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmDebug))
|
||||
ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))
|
||||
ASM_GLOBAL ASM_PFX(gSmiHandlerIdtr)
|
||||
|
||||
@@ -148,43 +147,22 @@ L5:
|
||||
# jmp _SmiHandler # instruction is not needed
|
||||
|
||||
_SmiHandler:
|
||||
cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmDebug))
|
||||
jz L3
|
||||
|
||||
L6:
|
||||
call L1
|
||||
L1:
|
||||
popl %ebp
|
||||
movl $0x80000001, %eax
|
||||
cpuid
|
||||
btl $29, %edx # check cpuid to identify X64 or IA32
|
||||
leal (0x7fc8 - (L1 - _SmiEntryPoint))(%ebp), %edi
|
||||
leal 4(%edi), %esi
|
||||
jnc L2
|
||||
addl $4, %esi
|
||||
L2:
|
||||
movl (%esi), %ecx
|
||||
movl (%edi), %edx
|
||||
L7:
|
||||
movl %ecx, %dr6
|
||||
movl %edx, %dr7 # restore DR6 & DR7 before running C code
|
||||
L3:
|
||||
|
||||
pushl (%esp)
|
||||
movl (%esp), %ebx
|
||||
|
||||
pushl %ebx
|
||||
movl $ASM_PFX(CpuSmmDebugEntry), %eax
|
||||
call *%eax
|
||||
popl %ecx
|
||||
|
||||
pushl %ebx
|
||||
movl $ASM_PFX(SmiRendezvous), %eax
|
||||
call *%eax
|
||||
popl %ecx
|
||||
|
||||
|
||||
cmpb $0, ASM_PFX(FeaturePcdGet (PcdCpuSmmDebug))
|
||||
jz L4
|
||||
|
||||
movl %dr6, %ecx
|
||||
movl %dr7, %edx
|
||||
movl %ecx, (%esi)
|
||||
movl %edx, (%edi)
|
||||
L4:
|
||||
pushl %ebx
|
||||
movl $ASM_PFX(CpuSmmDebugExit), %eax
|
||||
call *%eax
|
||||
popl %ecx
|
||||
|
||||
rsm
|
||||
|
||||
|
@@ -34,14 +34,15 @@ PROTECT_MODE_CS EQU 08h
|
||||
PROTECT_MODE_DS EQU 20h
|
||||
TSS_SEGMENT EQU 40h
|
||||
|
||||
SmiRendezvous PROTO C
|
||||
SmiRendezvous PROTO C
|
||||
CpuSmmDebugEntry PROTO C
|
||||
CpuSmmDebugExit PROTO C
|
||||
|
||||
EXTERNDEF gcSmiHandlerTemplate:BYTE
|
||||
EXTERNDEF gcSmiHandlerSize:WORD
|
||||
EXTERNDEF gSmiCr3:DWORD
|
||||
EXTERNDEF gSmiStack:DWORD
|
||||
EXTERNDEF gSmbase:DWORD
|
||||
EXTERNDEF FeaturePcdGet (PcdCpuSmmDebug):BYTE
|
||||
EXTERNDEF FeaturePcdGet (PcdCpuSmmStackGuard):BYTE
|
||||
EXTERNDEF gSmiHandlerIdtr:FWORD
|
||||
|
||||
@@ -151,40 +152,23 @@ gSmiCr3 DD ?
|
||||
; jmp _SmiHandler ; instruction is not needed
|
||||
|
||||
_SmiHandler PROC
|
||||
cmp FeaturePcdGet (PcdCpuSmmDebug), 0
|
||||
jz @3
|
||||
call @1
|
||||
@1:
|
||||
pop ebp
|
||||
mov eax, 80000001h
|
||||
cpuid
|
||||
bt edx, 29 ; check cpuid to identify X64 or IA32
|
||||
lea edi, [ebp - (@1 - _SmiEntryPoint) + 7fc8h]
|
||||
lea esi, [edi + 4]
|
||||
jnc @2
|
||||
add esi, 4
|
||||
@2:
|
||||
mov ecx, [esi]
|
||||
mov edx, [edi]
|
||||
@5:
|
||||
mov dr6, ecx
|
||||
mov dr7, edx ; restore DR6 & DR7 before running C code
|
||||
@3:
|
||||
mov ecx, [esp] ; CPU Index
|
||||
mov ebx, [esp] ; CPU Index
|
||||
|
||||
push ecx
|
||||
mov eax, SmiRendezvous
|
||||
push ebx
|
||||
mov eax, CpuSmmDebugEntry
|
||||
call eax
|
||||
pop ecx
|
||||
|
||||
cmp FeaturePcdGet (PcdCpuSmmDebug), 0
|
||||
jz @4
|
||||
push ebx
|
||||
mov eax, SmiRendezvous
|
||||
call eax
|
||||
pop ecx
|
||||
|
||||
push ebx
|
||||
mov eax, CpuSmmDebugExit
|
||||
call eax
|
||||
pop ecx
|
||||
|
||||
mov ecx, dr6
|
||||
mov edx, dr7
|
||||
mov [esi], ecx
|
||||
mov [edi], edx
|
||||
@4:
|
||||
rsm
|
||||
_SmiHandler ENDP
|
||||
|
||||
|
Reference in New Issue
Block a user