summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
diff options
context:
space:
mode:
authorYao, Jiewen <jiewen.yao@intel.com>2015-11-25 08:51:15 +0000
committerjyao1 <jyao1@Edk2>2015-11-25 08:51:15 +0000
commitf45f2d4ad4d803eb33c608bca8242992f1841fec (patch)
treebe1c3e7e9487cf8deb505a87b076bb64329bb952 /UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
parent0b256fb1dd7ca267d6e448768e519f54f97f347a (diff)
downloadedk2-platforms-f45f2d4ad4d803eb33c608bca8242992f1841fec.tar.xz
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
Diffstat (limited to 'UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm47
1 files changed, 15 insertions, 32 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
index 4d53db5b00..4f5c03c5cf 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
@@ -22,12 +22,13 @@
; Variables referenced by C code
;
EXTERNDEF SmiRendezvous:PROC
+EXTERNDEF CpuSmmDebugEntry:PROC
+EXTERNDEF CpuSmmDebugExit:PROC
EXTERNDEF gcSmiHandlerTemplate:BYTE
EXTERNDEF gcSmiHandlerSize:WORD
EXTERNDEF gSmiCr3:DWORD
EXTERNDEF gSmiStack:DWORD
EXTERNDEF gSmbase:DWORD
-EXTERNDEF FeaturePcdGet (PcdCpuSmmDebug):BYTE
EXTERNDEF gSmiHandlerIdtr:FWORD
@@ -157,26 +158,7 @@ Base:
; jmp _SmiHandler ; instruction is not needed
_SmiHandler:
-;
-; The following lines restore DR6 & DR7 before running C code. They are useful
-; when you want to enable hardware breakpoints in SMM.
-;
-; NOTE: These lines might not be appreciated in runtime since they might
-; conflict with OS debugging facilities. Turn them off in RELEASE.
-;
- mov rax, offset FeaturePcdGet (PcdCpuSmmDebug) ;Get absolute address. Avoid RIP relative addressing
- cmp byte ptr [rax], 0
- jz @1
-
- DB 48h, 8bh, 0dh ; mov rcx, [rip + disp32]
- DD SSM_DR6 - ($ + 4 - _SmiEntryPoint + 8000h)
- DB 48h, 8bh, 15h ; mov rdx, [rip + disp32]
- DD SSM_DR7 - ($ + 4 - _SmiEntryPoint + 8000h)
- mov dr6, rcx
- mov dr7, rdx
-@1:
- mov rcx, [rsp] ; rcx <- CpuIndex
- mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous
+ mov rbx, [rsp] ; rbx <- CpuIndex
;
; Save FP registers
@@ -186,7 +168,19 @@ _SmiHandler:
fxsave [rsp]
add rsp, -20h
+
+ mov rcx, rbx
+ mov rax, CpuSmmDebugEntry
+ call rax
+
+ mov rcx, rbx
+ mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous
+ call rax
+
+ mov rcx, rbx
+ mov rax, CpuSmmDebugExit
call rax
+
add rsp, 20h
;
@@ -195,17 +189,6 @@ _SmiHandler:
DB 48h ; FXRSTOR64
fxrstor [rsp]
- mov rax, offset FeaturePcdGet (PcdCpuSmmDebug) ;Get absolute address. Avoid RIP relative addressing
- cmp byte ptr [rax], 0
- jz @2
-
- mov rdx, dr7
- mov rcx, dr6
- DB 48h, 89h, 15h ; mov [rip + disp32], rdx
- DD SSM_DR7 - ($ + 4 - _SmiEntryPoint + 8000h)
- DB 48h, 89h, 0dh ; mov [rip + disp32], rcx
- DD SSM_DR6 - ($ + 4 - _SmiEntryPoint + 8000h)
-@2:
rsm
gcSmiHandlerSize DW $ - _SmiEntryPoint