Add X64 support for DebugSupport driver.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2067 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -2041,6 +2041,168 @@
|
|||||||
<FfsFormatKey>BS_DRIVER</FfsFormatKey>
|
<FfsFormatKey>BS_DRIVER</FfsFormatKey>
|
||||||
</ModuleSaBuildOptions>
|
</ModuleSaBuildOptions>
|
||||||
</ModuleSA>
|
</ModuleSA>
|
||||||
|
<ModuleSA SupArchList="X64" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="911D584C-35F7-4955-BEF9-B452769DDC3A">
|
||||||
|
<Libraries>
|
||||||
|
<Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
</Libraries>
|
||||||
|
<PcdBuildDefinition>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdMaximumUnicodeStringLength</C_Name>
|
||||||
|
<Token>0x00000001</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>1000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdMaximumAsciiStringLength</C_Name>
|
||||||
|
<Token>0x00000002</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>1000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdMaximumLinkedListLength</C_Name>
|
||||||
|
<Token>0x00000003</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>1000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdSpinLockTimeout</C_Name>
|
||||||
|
<Token>0x00000004</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>10000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdReportStatusCodePropertyMask</C_Name>
|
||||||
|
<Token>0x00000007</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT8</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>0x06</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdDebugPropertyMask</C_Name>
|
||||||
|
<Token>0x00000005</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT8</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>0x0f</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdDebugClearMemoryValue</C_Name>
|
||||||
|
<Token>0x00000008</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT8</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>0xAF</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdDebugPrintErrorLevel</C_Name>
|
||||||
|
<Token>0x00000006</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>0x80000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
</PcdBuildDefinition>
|
||||||
|
<ModuleSaBuildOptions>
|
||||||
|
<FvBinding>NULL</FvBinding>
|
||||||
|
<FfsFormatKey>BS_DRIVER</FfsFormatKey>
|
||||||
|
</ModuleSaBuildOptions>
|
||||||
|
</ModuleSA>
|
||||||
|
<ModuleSA SupArchList="IPF" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="911D584C-35F7-4955-BEF9-B452769DDC3A">
|
||||||
|
<Libraries>
|
||||||
|
<Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
<Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
</Libraries>
|
||||||
|
<PcdBuildDefinition>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdMaximumUnicodeStringLength</C_Name>
|
||||||
|
<Token>0x00000001</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>1000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdMaximumAsciiStringLength</C_Name>
|
||||||
|
<Token>0x00000002</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>1000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdMaximumLinkedListLength</C_Name>
|
||||||
|
<Token>0x00000003</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>1000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdSpinLockTimeout</C_Name>
|
||||||
|
<Token>0x00000004</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>10000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdReportStatusCodePropertyMask</C_Name>
|
||||||
|
<Token>0x00000007</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT8</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>0x06</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdDebugPropertyMask</C_Name>
|
||||||
|
<Token>0x00000005</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT8</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>0x0f</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdDebugClearMemoryValue</C_Name>
|
||||||
|
<Token>0x00000008</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT8</DatumType>
|
||||||
|
<MaxDatumSize>1</MaxDatumSize>
|
||||||
|
<Value>0xAF</Value>
|
||||||
|
</PcdData>
|
||||||
|
<PcdData ItemType="FIXED_AT_BUILD">
|
||||||
|
<C_Name>PcdDebugPrintErrorLevel</C_Name>
|
||||||
|
<Token>0x00000006</Token>
|
||||||
|
<TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
|
||||||
|
<DatumType>UINT32</DatumType>
|
||||||
|
<MaxDatumSize>4</MaxDatumSize>
|
||||||
|
<Value>0x80000000</Value>
|
||||||
|
</PcdData>
|
||||||
|
</PcdBuildDefinition>
|
||||||
|
<ModuleSaBuildOptions>
|
||||||
|
<FvBinding>NULL</FvBinding>
|
||||||
|
<FfsFormatKey>BS_DRIVER</FfsFormatKey>
|
||||||
|
</ModuleSaBuildOptions>
|
||||||
|
</ModuleSA>
|
||||||
<ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="9E863906-A40F-4875-977F-5B93FF237FC6">
|
<ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="9E863906-A40F-4875-977F-5B93FF237FC6">
|
||||||
<Libraries>
|
<Libraries>
|
||||||
<Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
<Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
|
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<MsaHeader>
|
<MsaHeader>
|
||||||
<ModuleName>DebugSupport</ModuleName>
|
<ModuleName>DebugSupport</ModuleName>
|
||||||
<ModuleType>DXE_DRIVER</ModuleType>
|
<ModuleType>DXE_DRIVER</ModuleType>
|
||||||
@ -37,6 +37,9 @@
|
|||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||||
</LibraryClass>
|
</LibraryClass>
|
||||||
|
<LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IA32 X64 IPF EBC">
|
||||||
|
<Keyword>BaseLib</Keyword>
|
||||||
|
</LibraryClass>
|
||||||
</LibraryClassDefinitions>
|
</LibraryClassDefinitions>
|
||||||
<SourceFiles>
|
<SourceFiles>
|
||||||
<Filename>DebugSupport.c</Filename>
|
<Filename>DebugSupport.c</Filename>
|
||||||
@ -49,6 +52,10 @@
|
|||||||
<Filename SupArchList="IPF">ipf/common.i</Filename>
|
<Filename SupArchList="IPF">ipf/common.i</Filename>
|
||||||
<Filename SupArchList="IPF">ipf/ds64macros.i</Filename>
|
<Filename SupArchList="IPF">ipf/ds64macros.i</Filename>
|
||||||
<Filename SupArchList="IPF">ipf/plDebugSupport.c</Filename>
|
<Filename SupArchList="IPF">ipf/plDebugSupport.c</Filename>
|
||||||
|
<Filename SupArchList="IPF">ipf/plDebugSupport.h</Filename>
|
||||||
|
<Filename SupArchList="X64">x64/AsmFuncs.asm</Filename>
|
||||||
|
<Filename SupArchList="X64">x64/plDebugSupport.h</Filename>
|
||||||
|
<Filename SupArchList="X64">x64/plDebugSupport.c</Filename>
|
||||||
</SourceFiles>
|
</SourceFiles>
|
||||||
<PackageDependencies>
|
<PackageDependencies>
|
||||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||||
|
@ -80,14 +80,14 @@ OrigVector dd 66666666h ; ?
|
|||||||
;; For reference, the context structure looks like this:
|
;; For reference, the context structure looks like this:
|
||||||
;; struct {
|
;; struct {
|
||||||
;; UINT32 ExceptionData;
|
;; UINT32 ExceptionData;
|
||||||
;; FX_SAVE_STATE FxSaveState; // 512 bytes, must be 16 byte aligned
|
;; FX_SAVE_STATE_IA32 FxSaveState; // 512 bytes, must be 16 byte aligned
|
||||||
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||||
;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
|
;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
|
||||||
;; UINT32 Ldtr, Tr;
|
|
||||||
;; UINT64 Gdtr, Idtr;
|
|
||||||
;; UINT32 EFlags;
|
;; UINT32 EFlags;
|
||||||
|
;; UINT32 Ldtr, Tr;
|
||||||
|
;; UINT32 Gdtr[2], Idtr[2];
|
||||||
;; UINT32 Eip;
|
;; UINT32 Eip;
|
||||||
;; UINT32 SegGs, SegFs, SegEs, SegDs, SegCs, SegSs;
|
;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
|
||||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||||
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record
|
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record
|
||||||
|
|
||||||
@ -252,14 +252,14 @@ CommonIdtEntry::
|
|||||||
;; typedef
|
;; typedef
|
||||||
;; struct {
|
;; struct {
|
||||||
;; UINT32 ExceptionData;
|
;; UINT32 ExceptionData;
|
||||||
;; FX_SAVE_STATE FxSaveState;
|
;; FX_SAVE_STATE_IA32 FxSaveState;
|
||||||
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||||
;; UINT32 Cr0, Cr2, Cr3, Cr4;
|
;; UINT32 Cr0, Cr2, Cr3, Cr4;
|
||||||
;; UINT32 Ldtr, Tr;
|
|
||||||
;; UINT64 Gdtr, Idtr;
|
|
||||||
;; UINT32 EFlags;
|
;; UINT32 EFlags;
|
||||||
|
;; UINT32 Ldtr, Tr;
|
||||||
|
;; UINT32 Gdtr[2], Idtr[2];
|
||||||
;; UINT32 Eip;
|
;; UINT32 Eip;
|
||||||
;; UINT32 SegGs, SegFs, SegEs, SegDs, SegCs, SegSs;
|
;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
|
||||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||||
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record
|
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ CommonIdtEntry::
|
|||||||
mov eax, AppEsp
|
mov eax, AppEsp
|
||||||
push dword ptr [eax]
|
push dword ptr [eax]
|
||||||
|
|
||||||
;; UINT64 Gdtr, Idtr;
|
;; UINT32 Gdtr[2], Idtr[2];
|
||||||
push 0
|
push 0
|
||||||
push 0
|
push 0
|
||||||
sidt fword ptr [esp]
|
sidt fword ptr [esp]
|
||||||
@ -397,7 +397,7 @@ CommonIdtEntry::
|
|||||||
mov eax, dr0
|
mov eax, dr0
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
;; FX_SAVE_STATE FxSaveState;
|
;; FX_SAVE_STATE_IA32 FxSaveState;
|
||||||
sub esp, 512
|
sub esp, 512
|
||||||
mov edi, esp
|
mov edi, esp
|
||||||
; IMPORTANT!! The debug stack has been carefully constructed to
|
; IMPORTANT!! The debug stack has been carefully constructed to
|
||||||
@ -422,7 +422,7 @@ CommonIdtEntry::
|
|||||||
;; UINT32 ExceptionData;
|
;; UINT32 ExceptionData;
|
||||||
add esp, 4
|
add esp, 4
|
||||||
|
|
||||||
;; FX_SAVE_STATE FxSaveState;
|
;; FX_SAVE_STATE_IA32 FxSaveState;
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
FXRSTOR_ESI
|
FXRSTOR_ESI
|
||||||
add esp, 512
|
add esp, 512
|
||||||
@ -456,8 +456,8 @@ CommonIdtEntry::
|
|||||||
mov eax, AppEsp
|
mov eax, AppEsp
|
||||||
pop dword ptr [eax + 8]
|
pop dword ptr [eax + 8]
|
||||||
|
|
||||||
;; UINT16 Ldtr, Tr;
|
;; UINT32 Ldtr, Tr;
|
||||||
;; UINT64 Gdtr, Idtr;
|
;; UINT32 Gdtr[2], Idtr[2];
|
||||||
;; Best not let anyone mess with these particular registers...
|
;; Best not let anyone mess with these particular registers...
|
||||||
add esp, 24
|
add esp, 24
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ CommonIdtEntry::
|
|||||||
pop ss
|
pop ss
|
||||||
|
|
||||||
;; The next stuff to restore is the general purpose registers that were pushed
|
;; The next stuff to restore is the general purpose registers that were pushed
|
||||||
;; using the pushad instruction.
|
;; using the "pushad" instruction.
|
||||||
;;
|
;;
|
||||||
;; The value of ESP as stored in the context record is the application ESP
|
;; The value of ESP as stored in the context record is the application ESP
|
||||||
;; including the 3 entries on the application stack caused by the exception
|
;; including the 3 entries on the application stack caused by the exception
|
||||||
@ -505,7 +505,7 @@ CommonIdtEntry::
|
|||||||
mov AppEsp, eax
|
mov AppEsp, eax
|
||||||
NoAppStackMove:
|
NoAppStackMove:
|
||||||
mov eax, DebugEsp ; restore the DebugEsp on the debug stack
|
mov eax, DebugEsp ; restore the DebugEsp on the debug stack
|
||||||
; so our popad will not cause a stack switch
|
; so our "popad" will not cause a stack switch
|
||||||
mov [esp + 12], eax
|
mov [esp + 12], eax
|
||||||
|
|
||||||
cmp ExceptionNumber, 068h
|
cmp ExceptionNumber, 068h
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*++
|
/**@file
|
||||||
|
IA32 specific debug support functions
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006 Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -9,17 +10,7 @@ http://opensource.org/licenses/bsd-license.php
|
|||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
**/
|
||||||
|
|
||||||
plDebugSupport.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
IA32 specific debug support functions
|
|
||||||
|
|
||||||
Revision History
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// private header files
|
// private header files
|
||||||
@ -117,7 +108,6 @@ Returns:
|
|||||||
Other possibilities are passed through by CreateEntryStub
|
Other possibilities are passed through by CreateEntryStub
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ) - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
BOOLEAN OldIntFlagState;
|
BOOLEAN OldIntFlagState;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -199,7 +189,6 @@ Returns:
|
|||||||
Other possible return values are passed through from UnHookEntry and HookEntry.
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ) - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
@ -246,12 +235,13 @@ GetMaximumProcessorIndex (
|
|||||||
Routine Description: This is a DebugSupport protocol member function.
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
MaxProcessorIndex - The maximuim supported processor index
|
||||||
|
|
||||||
Returns: Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
Returns:
|
||||||
|
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: MaxProcessorIndex - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
*MaxProcessorIndex = 0;
|
*MaxProcessorIndex = 0;
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
@ -269,13 +259,20 @@ RegisterPeriodicCallback (
|
|||||||
Routine Description: This is a DebugSupport protocol member function.
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
PeriodicCallback - Callback function
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: ProcessorIndex - add argument and description to function comment
|
|
||||||
// TODO: PeriodicCallback - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);
|
return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);
|
||||||
}
|
}
|
||||||
@ -296,16 +293,21 @@ Routine Description:
|
|||||||
This code executes in boot services context.
|
This code executes in boot services context.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
NewCallback - Callback function
|
||||||
|
ExceptionType - Which exception to hook
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
None
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: ProcessorIndex - add argument and description to function comment
|
|
||||||
// TODO: NewCallback - add argument and description to function comment
|
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
return ManageIdtEntryTable (NewCallback, ExceptionType);
|
return ManageIdtEntryTable (NewCallback, ExceptionType);
|
||||||
}
|
}
|
||||||
@ -322,21 +324,21 @@ InvalidateInstructionCache (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
This is a DebugSupport protocol member function.
|
This is a DebugSupport protocol member function.
|
||||||
For IA32, this is a no-op since the instruction and data caches are coherent.
|
Calls assembly routine to flush cache.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
Start - Physical base of the memory range to be invalidated
|
||||||
|
Length - mininum number of bytes in instruction cache to invalidate
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
None
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: ProcessorIndex - add argument and description to function comment
|
|
||||||
// TODO: Start - add argument and description to function comment
|
|
||||||
// TODO: Length - add argument and description to function comment
|
|
||||||
// TODO: EFI_SUCCESS - add return value to function comment
|
|
||||||
{
|
{
|
||||||
|
AsmWbinvd ();
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,9 +360,9 @@ Returns:
|
|||||||
EFI_SUCCESS
|
EFI_SUCCESS
|
||||||
EFI_UNSUPPORTED - if IA32 processor does not support FXSTOR/FXRSTOR instructions,
|
EFI_UNSUPPORTED - if IA32 processor does not support FXSTOR/FXRSTOR instructions,
|
||||||
the context save will fail, so these processor's are not supported.
|
the context save will fail, so these processor's are not supported.
|
||||||
|
EFI_OUT_OF_RESOURCES - not resource to finish initialization
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
|
|
||||||
{
|
{
|
||||||
if (!FxStorSupport ()) {
|
if (!FxStorSupport ()) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
@ -393,10 +395,9 @@ Arguments:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
None
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: EFI_SUCCESS - add return value to function comment
|
|
||||||
{
|
{
|
||||||
EFI_EXCEPTION_TYPE ExceptionType;
|
EFI_EXCEPTION_TYPE ExceptionType;
|
||||||
|
|
||||||
@ -420,14 +421,14 @@ Routine Description: Common piece of code that invokes the registered handlers.
|
|||||||
This code executes in exception context so no efi calls are allowed.
|
This code executes in exception context so no efi calls are allowed.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
ExceptionType - exception type
|
||||||
|
ContextRecord - system context
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
// TODO: ContextRecord - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {
|
if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {
|
||||||
if (ExceptionType != SYSTEM_TIMER_VECTOR) {
|
if (ExceptionType != SYSTEM_TIMER_VECTOR) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/*++
|
/**@file
|
||||||
|
IA32 specific debug support macros, typedefs and prototypes.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
@ -9,17 +10,7 @@ http://opensource.org/licenses/bsd-license.php
|
|||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
**/
|
||||||
|
|
||||||
plDebugSupport.h
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
IA32 specific debug support macros, typedefs and prototypes.
|
|
||||||
|
|
||||||
Revision History
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
#ifndef _PLDEBUG_SUPPORT_H
|
#ifndef _PLDEBUG_SUPPORT_H
|
||||||
#define _PLDEBUG_SUPPORT_H
|
#define _PLDEBUG_SUPPORT_H
|
||||||
@ -58,7 +49,7 @@ CommonIdtEntry (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
TODO: Add function description
|
Generic IDT entry
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
@ -66,11 +57,12 @@ Arguments:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
None
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
FxStorSupport (
|
FxStorSupport (
|
||||||
VOID
|
VOID
|
||||||
@ -79,7 +71,7 @@ FxStorSupport (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
TODO: Add function description
|
Check whether FXSTOR is supported
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
@ -87,7 +79,8 @@ Arguments:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
TRUE - supported
|
||||||
|
FALSE - not supported
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -100,7 +93,7 @@ GetIdtr (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
TODO: Add function description
|
Return the physical address of IDTR
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
@ -108,7 +101,7 @@ Arguments:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
The physical address of IDTR
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -122,16 +115,16 @@ Vect2Desc (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
TODO: Add function description
|
Encodes an IDT descriptor with the given physical address
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
DestDesc - TODO: add argument description
|
DestDesc - The IDT descriptor address
|
||||||
) - TODO: add argument description
|
Vector - The interrupt vector entry
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
None
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -144,15 +137,16 @@ WriteInterruptFlag (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
|
||||||
TODO: Add function description
|
Programs interrupt flag to the requested state and returns previous
|
||||||
|
state.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
NewState - TODO: add argument description
|
NewState - New interrupt status
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
Old interrupt status
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -164,16 +158,18 @@ plInitializeDebugSupportDriver (
|
|||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
Initializes driver's handler registration database.
|
||||||
|
|
||||||
TODO: Add function description
|
This code executes in boot services context.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
TODO: add return values
|
EFI_UNSUPPORTED - if IA32 processor does not support FXSTOR/FXRSTOR instructions,
|
||||||
|
the context save will fail, so these processor's are not supported.
|
||||||
|
EFI_OUT_OF_RESOURCES - not resource to finish initialization
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -186,16 +182,18 @@ plUnloadDebugSupportDriver (
|
|||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
This is the callback that is written to the LoadedImage protocol instance
|
||||||
|
on the image handle. It uninstalls all registered handlers and frees all entry
|
||||||
|
stub memory.
|
||||||
|
|
||||||
TODO: Add function description
|
This code executes in boot services context.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
ImageHandle - The image handle of the unload handler
|
||||||
ImageHandle - TODO: add argument description
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -211,18 +209,14 @@ GetMaximumProcessorIndex (
|
|||||||
)
|
)
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
TODO: Add function description
|
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
This - TODO: add argument description
|
MaxProcessorIndex - The maximuim supported processor index
|
||||||
MaxProcessorIndex - TODO: add argument description
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||||
TODO: add return values
|
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -236,19 +230,21 @@ RegisterPeriodicCallback (
|
|||||||
)
|
)
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
TODO: Add function description
|
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
This - TODO: add argument description
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
ProcessorIndex - TODO: add argument description
|
PeriodicCallback - Callback function
|
||||||
PeriodicCallback - TODO: add argument description
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -264,19 +260,24 @@ RegisterExceptionCallback (
|
|||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
TODO: Add function description
|
This code executes in boot services context.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
This - TODO: add argument description
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
ProcessorIndex - TODO: add argument description
|
NewCallback - Callback function
|
||||||
NewCallback - TODO: add argument description
|
ExceptionType - Which exception to hook
|
||||||
ExceptionType - TODO: add argument description
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
@ -292,19 +293,18 @@ InvalidateInstructionCache (
|
|||||||
/*++
|
/*++
|
||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
|
This is a DebugSupport protocol member function.
|
||||||
TODO: Add function description
|
Calls assembly routine to flush cache.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
This - TODO: add argument description
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
ProcessorIndex - TODO: add argument description
|
Start - Physical base of the memory range to be invalidated
|
||||||
Start - TODO: add argument description
|
Length - mininum number of bytes in instruction cache to invalidate
|
||||||
Length - TODO: add argument description
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
TODO: add return values
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
;
|
;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/*++
|
/**@file
|
||||||
|
IPF specific debug support functions
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
@ -9,32 +10,7 @@ http://opensource.org/licenses/bsd-license.php
|
|||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
**/
|
||||||
|
|
||||||
PlDebugSupport.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
IPF specific debug support functions
|
|
||||||
|
|
||||||
Revision History
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// Master EFI header file
|
|
||||||
//
|
|
||||||
#include "Tiano.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Common library header files
|
|
||||||
//
|
|
||||||
#include "EfiDriverLib.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Produced protocols
|
|
||||||
//
|
|
||||||
#include EFI_PROTOCOL_DEFINITION (DebugSupport)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// private header files
|
// private header files
|
||||||
@ -148,14 +124,13 @@ Routine Description:
|
|||||||
used by the driver. Must be public because it's referenced from DebugSuport.c
|
used by the driver. Must be public because it's referenced from DebugSuport.c
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_HANDLE ImageHandle
|
ImageHandle - Image handle
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ImageHandle - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
EFI_EXCEPTION_TYPE ExceptionType;
|
EFI_EXCEPTION_TYPE ExceptionType;
|
||||||
|
|
||||||
@ -178,22 +153,20 @@ Routine Description:
|
|||||||
exception dispatcher. Must be public because it's referenced from AsmFuncs.s.
|
exception dispatcher. Must be public because it's referenced from AsmFuncs.s.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
ExceptionType - Exception Type
|
||||||
IN EFI_SYSTEM_CONTEXT Context
|
Context - System Context
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
// TODO: Context - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
static BOOLEAN InHandler = FALSE;
|
static BOOLEAN InHandler = FALSE;
|
||||||
|
|
||||||
DEBUG_CODE_BEGIN ();
|
DEBUG_CODE_BEGIN ();
|
||||||
if (InHandler) {
|
if (InHandler) {
|
||||||
EfiDebugPrint (EFI_D_GENERIC, "ERROR: Re-entered debugger!\n"
|
DEBUG ((EFI_D_INFO, "ERROR: Re-entered debugger!\n"
|
||||||
" ExceptionType == %X\n"
|
" ExceptionType == %X\n"
|
||||||
" Context == %X\n"
|
" Context == %X\n"
|
||||||
" Context.SystemContextIpf->CrIip == %X\n"
|
" Context.SystemContextIpf->CrIip == %X\n"
|
||||||
@ -203,7 +176,7 @@ Returns:
|
|||||||
Context,
|
Context,
|
||||||
Context.SystemContextIpf->CrIip,
|
Context.SystemContextIpf->CrIip,
|
||||||
Context.SystemContextIpf->CrIpsr,
|
Context.SystemContextIpf->CrIpsr,
|
||||||
InHandler);
|
InHandler));
|
||||||
}
|
}
|
||||||
DEBUG_CODE_END ();
|
DEBUG_CODE_END ();
|
||||||
|
|
||||||
@ -234,16 +207,14 @@ Routine Description:
|
|||||||
Given an integer number, return the physical address of the entry point in the IFT
|
Given an integer number, return the physical address of the entry point in the IFT
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
UINTN HandlerIndex,
|
HandlerIndex - Index of the Handler
|
||||||
VOID ** EntryPoint
|
EntryPoint - IFT Entrypoint
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: HandlerIndex - add argument and description to function comment
|
|
||||||
// TODO: EntryPoint - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
UINT8 *TempPtr;
|
UINT8 *TempPtr;
|
||||||
|
|
||||||
@ -280,20 +251,17 @@ Routine Description:
|
|||||||
This is the worker function that installs and removes all handlers
|
This is the worker function that installs and removes all handlers
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
ExceptionType - Exception Type
|
||||||
IN BUNDLE NewBundles[NUM_BUNDLES_IN_STUB],
|
NewBundles - New Boundles
|
||||||
IN VOID (*NewCallback) ()
|
NewCallback - New Callback
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
EFI_STATUS - any return other than EFI_SUCCESS indicates the request was not
|
EFI_STATUS - any return other than EFI_SUCCESS indicates the request was not
|
||||||
satisfied.
|
satisfied.
|
||||||
|
EFI_ALEADY_STARTED - Ivt already hooked.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
// TODO: ] - add argument and description to function comment
|
|
||||||
// TODO: ) - add argument and description to function comment
|
|
||||||
// TODO: EFI_ALREADY_STARTED - add return value to function comment
|
|
||||||
{
|
{
|
||||||
BUNDLE *B0Ptr;
|
BUNDLE *B0Ptr;
|
||||||
UINT64 InterruptFlags;
|
UINT64 InterruptFlags;
|
||||||
@ -367,18 +335,15 @@ Routine Description:
|
|||||||
to store the ExceptionType and then call the common handler.
|
to store the ExceptionType and then call the common handler.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
ExceptionType - Exception Type
|
||||||
IN BUNDLE NewBundles[4],
|
NewBundles - New Boundles
|
||||||
IN VOID (*NewCallback) ()
|
NewCallback - New Callback
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
// TODO: ] - add argument and description to function comment
|
|
||||||
// TODO: ) - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
BUNDLE *FixupBundle;
|
BUNDLE *FixupBundle;
|
||||||
BUNDLE *B0Ptr;
|
BUNDLE *B0Ptr;
|
||||||
@ -422,14 +387,15 @@ Routine Description:
|
|||||||
Restores original IVT contents when unregistering a callback function
|
Restores original IVT contents when unregistering a callback function
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
ExceptionType - Exception Type
|
||||||
|
NewBundles - New Boundles
|
||||||
|
NewCallback - New Callback
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
BUNDLE *B0Ptr;
|
BUNDLE *B0Ptr;
|
||||||
|
|
||||||
@ -460,14 +426,13 @@ Routine Description:
|
|||||||
Records new callback in IvtEntryTable.
|
Records new callback in IvtEntryTable.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN VOID (*NewCallback) ()
|
NewCallback - New Callback
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: ) - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
VOID *Start;
|
VOID *Start;
|
||||||
|
|
||||||
@ -522,12 +487,13 @@ Routine Description: This is a DebugSupport protocol member function. Hard
|
|||||||
coded to support only 1 processor for now.
|
coded to support only 1 processor for now.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
MaxProcessorIndex - The maximuim supported processor index
|
||||||
|
|
||||||
Returns: Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
Returns:
|
||||||
|
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: MaxProcessorIndex - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
*MaxProcessorIndex = 0;
|
*MaxProcessorIndex = 0;
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
@ -546,18 +512,15 @@ Routine Description:
|
|||||||
DebugSupport protocol member function
|
DebugSupport protocol member function
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
This - The DebugSupport instance
|
||||||
IN UINTN ProcessorIndex,
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
IN EFI_PERIODIC_CALLBACK NewPeriodicCallback
|
PeriodicCallback - Callback function
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: ProcessorIndex - add argument and description to function comment
|
|
||||||
// TODO: NewPeriodicCallback - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
return ManageIvtEntryTable (EXCEPT_IPF_EXTERNAL_INTERRUPT, NULL, NewPeriodicCallback);
|
return ManageIvtEntryTable (EXCEPT_IPF_EXTERNAL_INTERRUPT, NULL, NewPeriodicCallback);
|
||||||
}
|
}
|
||||||
@ -576,19 +539,16 @@ Routine Description:
|
|||||||
DebugSupport protocol member function
|
DebugSupport protocol member function
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
This - The DebugSupport instance
|
||||||
IN EFI_EXCEPTION_CALLBACK NewCallback,
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
IN EFI_EXCEPTION_TYPE ExceptionType
|
NewCallback - Callback function
|
||||||
|
ExceptionType - Which exception to hook
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: ProcessorIndex - add argument and description to function comment
|
|
||||||
// TODO: NewCallback - add argument and description to function comment
|
|
||||||
// TODO: ExceptionType - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
return ManageIvtEntryTable (
|
return ManageIvtEntryTable (
|
||||||
ExceptionType,
|
ExceptionType,
|
||||||
@ -611,15 +571,15 @@ Routine Description:
|
|||||||
DebugSupport protocol member function. Calls assembly routine to flush cache.
|
DebugSupport protocol member function. Calls assembly routine to flush cache.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
Start - Physical base of the memory range to be invalidated
|
||||||
|
Length - mininum number of bytes in instruction cache to invalidate
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
EFI_SUCCESS
|
EFI_SUCCESS
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
// TODO: This - add argument and description to function comment
|
|
||||||
// TODO: ProcessorIndex - add argument and description to function comment
|
|
||||||
// TODO: Start - add argument and description to function comment
|
|
||||||
// TODO: Length - add argument and description to function comment
|
|
||||||
{
|
{
|
||||||
InstructionCacheFlush (Start, Length);
|
InstructionCacheFlush (Start, Length);
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
|
297
EdkModulePkg/Universal/DebugSupport/Dxe/ipf/plDebugSupport.h
Normal file
297
EdkModulePkg/Universal/DebugSupport/Dxe/ipf/plDebugSupport.h
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
/**@file
|
||||||
|
IPF specific debugsupport types, macros, and definitions.
|
||||||
|
|
||||||
|
Copyright (c) 2004 - 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _PLDEBUG_SUPPORT_H
|
||||||
|
#define _PLDEBUG_SUPPORT_H
|
||||||
|
|
||||||
|
|
||||||
|
#define DISABLE_INTERRUPTS 0UL
|
||||||
|
|
||||||
|
//
|
||||||
|
// The remaining definitions comprise the protocol members.
|
||||||
|
//
|
||||||
|
#define EFI_ISA IsaIpf
|
||||||
|
|
||||||
|
//
|
||||||
|
// processor specific functions that must be public
|
||||||
|
//
|
||||||
|
EFI_STATUS
|
||||||
|
plInitializeDebugSupportDriver (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
IPF specific DebugSupport driver initialization. Must be public because it's
|
||||||
|
referenced from DebugSupport.c
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
plUnloadDebugSupportDriver (
|
||||||
|
IN EFI_HANDLE ImageHandle
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Unload handler that is called during UnloadImage() - deallocates pool memory
|
||||||
|
used by the driver. Must be public because it's referenced from DebugSuport.c
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ImageHandle - Image handle
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Assembly worker functions and data referenced from plDebugSupport.c
|
||||||
|
//
|
||||||
|
VOID *
|
||||||
|
GetIva (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
C callable function to obtain the current value of IVA
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Current value if IVA
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
HookStub (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
HookStub will be copied from it's loaded location into the IVT when
|
||||||
|
an IVT entry is hooked.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ChainHandler (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Chains an interrupt handler
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
UnchainHandler (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Unchains an interrupt handler
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
UINT64
|
||||||
|
ProgramInterruptFlags (
|
||||||
|
IN UINT64 NewInterruptState
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
C callable function to enable/disable interrupts
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
NewInterruptState - New Interrupt State
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Previous state of psr.ic
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
InstructionCacheFlush (
|
||||||
|
IN VOID *StartAddress,
|
||||||
|
IN UINTN SizeInBytes
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Flushes instruction cache for specified number of bytes
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
StartAddress - Cache Start Address
|
||||||
|
SizeInBytes - Cache Size
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetMaximumProcessorIndex (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
OUT UINTN *MaxProcessorIndex
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: This is a DebugSupport protocol member function. Hard
|
||||||
|
coded to support only 1 processor for now.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
MaxProcessorIndex - The maximuim supported processor index
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterPeriodicCallback (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN EFI_PERIODIC_CALLBACK PeriodicCallback
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
DebugSupport protocol member function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
PeriodicCallback - Callback function
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterExceptionCallback (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN EFI_EXCEPTION_CALLBACK NewHandler,
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
DebugSupport protocol member function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
NewCallback - Callback function
|
||||||
|
ExceptionType - Which exception to hook
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_STATUS - anything other than EFI_SUCCESS indicates the callback was not registered.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InvalidateInstructionCache (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN VOID *Start,
|
||||||
|
IN UINTN Length
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
DebugSupport protocol member function. Calls assembly routine to flush cache.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
Start - Physical base of the memory range to be invalidated
|
||||||
|
Length - mininum number of bytes in instruction cache to invalidate
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
655
EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm
Normal file
655
EdkModulePkg/Universal/DebugSupport/Dxe/x64/AsmFuncs.asm
Normal file
@ -0,0 +1,655 @@
|
|||||||
|
;******************************************************************************
|
||||||
|
;*
|
||||||
|
;* 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.
|
||||||
|
;*
|
||||||
|
;******************************************************************************
|
||||||
|
|
||||||
|
EXCPT64_DIVIDE_ERROR EQU 0
|
||||||
|
EXCPT64_DEBUG EQU 1
|
||||||
|
EXCPT64_NMI EQU 2
|
||||||
|
EXCPT64_BREAKPOINT EQU 3
|
||||||
|
EXCPT64_OVERFLOW EQU 4
|
||||||
|
EXCPT64_BOUND EQU 5
|
||||||
|
EXCPT64_INVALID_OPCODE EQU 6
|
||||||
|
EXCPT64_DOUBLE_FAULT EQU 8
|
||||||
|
EXCPT64_INVALID_TSS EQU 10
|
||||||
|
EXCPT64_SEG_NOT_PRESENT EQU 11
|
||||||
|
EXCPT64_STACK_FAULT EQU 12
|
||||||
|
EXCPT64_GP_FAULT EQU 13
|
||||||
|
EXCPT64_PAGE_FAULT EQU 14
|
||||||
|
EXCPT64_FP_ERROR EQU 16
|
||||||
|
EXCPT64_ALIGNMENT_CHECK EQU 17
|
||||||
|
EXCPT64_MACHINE_CHECK EQU 18
|
||||||
|
EXCPT64_SIMD EQU 19
|
||||||
|
|
||||||
|
FXSTOR_FLAG EQU 01000000h ; bit cpuid 24 of feature flags
|
||||||
|
|
||||||
|
;; The FXSTOR and FXRSTOR commands are used for saving and restoring the x87,
|
||||||
|
;; MMX, SSE, SSE2, etc registers. The initialization of the debugsupport driver
|
||||||
|
;; MUST check the CPUID feature flags to see that these instructions are available
|
||||||
|
;; and fail to init if they are not.
|
||||||
|
|
||||||
|
;; fxstor [rdi]
|
||||||
|
FXSTOR_RDI MACRO
|
||||||
|
db 0fh, 0aeh, 00000111y ; mod = 00, reg/op = 000, r/m = 111 = [rdi]
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
;; fxrstor [rsi]
|
||||||
|
FXRSTOR_RSI MACRO
|
||||||
|
db 0fh, 0aeh, 00001110y ; mod = 00, reg/op = 001, r/m = 110 = [rsi]
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
data SEGMENT
|
||||||
|
|
||||||
|
public OrigVector, InterruptEntryStub, StubSize, CommonIdtEntry, FxStorSupport
|
||||||
|
|
||||||
|
StubSize dd InterruptEntryStubEnd - InterruptEntryStub
|
||||||
|
AppRsp dq 1111111111111111h ; ?
|
||||||
|
DebugRsp dq 2222222222222222h ; ?
|
||||||
|
ExtraPush dq 3333333333333333h ; ?
|
||||||
|
ExceptData dq 4444444444444444h ; ?
|
||||||
|
Rflags dq 5555555555555555h ; ?
|
||||||
|
OrigVector dq 6666666666666666h ; ?
|
||||||
|
|
||||||
|
;; The declarations below define the memory region that will be used for the debug stack.
|
||||||
|
;; The context record will be built by pushing register values onto this stack.
|
||||||
|
;; It is imparitive that alignment be carefully managed, since the FXSTOR and
|
||||||
|
;; FXRSTOR instructions will GP fault if their memory operand is not 16 byte aligned.
|
||||||
|
;;
|
||||||
|
;; The stub will switch stacks from the application stack to the debuger stack
|
||||||
|
;; and pushes the exception number.
|
||||||
|
;;
|
||||||
|
;; Then we building the context record on the stack. Since the stack grows down,
|
||||||
|
;; we push the fields of the context record from the back to the front. There
|
||||||
|
;; are 336 bytes of stack used prior allocating the 512 bytes of stack to be
|
||||||
|
;; used as the memory buffer for the fxstor instruction. Therefore address of
|
||||||
|
;; the buffer used for the FXSTOR instruction is &Eax - 336 - 512, which
|
||||||
|
;; must be 16 byte aligned.
|
||||||
|
;;
|
||||||
|
;; We carefully locate the stack to make this happen.
|
||||||
|
;;
|
||||||
|
;; For reference, the context structure looks like this:
|
||||||
|
;; struct {
|
||||||
|
;; UINT64 ExceptionData;
|
||||||
|
;; FX_SAVE_STATE_X64 FxSaveState; // 512 bytes, must be 16 byte aligned
|
||||||
|
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||||
|
;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8;
|
||||||
|
;; UINT64 RFlags;
|
||||||
|
;; UINT64 Ldtr, Tr;
|
||||||
|
;; UINT64 Gdtr[2], Idtr[2];
|
||||||
|
;; UINT64 Rip;
|
||||||
|
;; UINT64 Gs, Fs, Es, Ds, Cs, Ss;
|
||||||
|
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
|
||||||
|
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
|
||||||
|
;; } SYSTEM_CONTEXT_X64; // 64 bit system context record
|
||||||
|
|
||||||
|
align 16
|
||||||
|
DebugStackEnd db "DbgStkEnd >>>>>>" ;; 16 byte long string - must be 16 bytes to preserve alignment
|
||||||
|
dd 1ffch dup (000000000h) ;; 32K should be enough stack
|
||||||
|
;; This allocation is coocked to insure
|
||||||
|
;; that the the buffer for the FXSTORE instruction
|
||||||
|
;; will be 16 byte aligned also.
|
||||||
|
;;
|
||||||
|
ExceptionNumber dq ? ;; first entry will be the vector number pushed by the stub
|
||||||
|
|
||||||
|
DebugStackBegin db "<<<< DbgStkBegin" ;; initial debug ESP == DebugStackBegin, set in stub
|
||||||
|
|
||||||
|
data ENDS
|
||||||
|
|
||||||
|
text SEGMENT
|
||||||
|
|
||||||
|
externdef InterruptDistrubutionHub:near
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; VOID
|
||||||
|
; EfiWbinvd (
|
||||||
|
; VOID
|
||||||
|
; )
|
||||||
|
;
|
||||||
|
; Abstract: Writeback and invalidate cache
|
||||||
|
;
|
||||||
|
EfiWbinvd PROC PUBLIC
|
||||||
|
wbinvd
|
||||||
|
ret
|
||||||
|
EfiWbinvd ENDP
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; BOOLEAN
|
||||||
|
; FxStorSupport (
|
||||||
|
; void
|
||||||
|
; )
|
||||||
|
;
|
||||||
|
; Abstract: Returns TRUE if FxStor instructions are supported
|
||||||
|
;
|
||||||
|
FxStorSupport PROC PUBLIC
|
||||||
|
|
||||||
|
;
|
||||||
|
; cpuid corrupts rbx which must be preserved per the C calling convention
|
||||||
|
;
|
||||||
|
push rbx
|
||||||
|
mov rax, 1
|
||||||
|
cpuid
|
||||||
|
mov eax, edx
|
||||||
|
and rax, FXSTOR_FLAG
|
||||||
|
shr rax, 24
|
||||||
|
pop rbx
|
||||||
|
ret
|
||||||
|
FxStorSupport ENDP
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; DESCRIPTOR *
|
||||||
|
; GetIdtr (
|
||||||
|
; void
|
||||||
|
; )
|
||||||
|
;
|
||||||
|
; Abstract: Returns physical address of IDTR
|
||||||
|
;
|
||||||
|
GetIdtr PROC PUBLIC
|
||||||
|
push rbp
|
||||||
|
mov rbp, rsp
|
||||||
|
|
||||||
|
sub rsp, 8h
|
||||||
|
sidt QWORD PTR [rbp - 6]
|
||||||
|
mov rax, QWORD PTR [rbp - 4]
|
||||||
|
|
||||||
|
mov rsp, rbp
|
||||||
|
pop rbp
|
||||||
|
ret
|
||||||
|
GetIdtr ENDP
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; BOOLEAN
|
||||||
|
; WriteInterruptFlag (
|
||||||
|
; BOOLEAN NewState // rcx
|
||||||
|
; )
|
||||||
|
;
|
||||||
|
; Abstract: Programs interrupt flag to the requested state and returns previous
|
||||||
|
; state.
|
||||||
|
;
|
||||||
|
WriteInterruptFlag PROC PUBLIC
|
||||||
|
|
||||||
|
pushfq
|
||||||
|
pop rax
|
||||||
|
and rax, 200h
|
||||||
|
shr rax, 9
|
||||||
|
cmp rcx, 0
|
||||||
|
jnz EnableIF
|
||||||
|
cli
|
||||||
|
ret
|
||||||
|
EnableIF:
|
||||||
|
sti
|
||||||
|
ret
|
||||||
|
|
||||||
|
WriteInterruptFlag ENDP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; void
|
||||||
|
; Vect2Desc (
|
||||||
|
; DESCRIPTOR * DestDesc, // rcx
|
||||||
|
; void (*Vector) (void) // rdx
|
||||||
|
; )
|
||||||
|
;
|
||||||
|
; Abstract: Encodes an IDT descriptor with the given physical address
|
||||||
|
;
|
||||||
|
Vect2Desc PROC PUBLIC
|
||||||
|
|
||||||
|
mov rax, rdx
|
||||||
|
mov word ptr [rcx], ax ; write bits 15..0 of offset
|
||||||
|
mov dx, cs
|
||||||
|
mov word ptr [rcx+2], dx ; SYS_CODE_SEL from GDT
|
||||||
|
mov word ptr [rcx+4], 0e00h OR 8000h ; type = 386 interrupt gate, present
|
||||||
|
shr rax, 16
|
||||||
|
mov word ptr [rcx+6], ax ; write bits 31..16 of offset
|
||||||
|
shr rax, 16
|
||||||
|
mov dword ptr [rcx+8], eax ; write bits 63..32 of offset
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
Vect2Desc ENDP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; InterruptEntryStub
|
||||||
|
;
|
||||||
|
; Abstract: This code is not a function, but is a small piece of code that is
|
||||||
|
; copied and fixed up once for each IDT entry that is hooked.
|
||||||
|
;
|
||||||
|
InterruptEntryStub::
|
||||||
|
push 0 ; push vector number - will be modified before installed
|
||||||
|
db 0e9h ; jump rel32
|
||||||
|
dd 0 ; fixed up to relative address of CommonIdtEntry
|
||||||
|
InterruptEntryStubEnd:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; CommonIdtEntry
|
||||||
|
;
|
||||||
|
; Abstract: This code is not a function, but is the common part for all IDT
|
||||||
|
; vectors.
|
||||||
|
;
|
||||||
|
CommonIdtEntry::
|
||||||
|
;;
|
||||||
|
;; At this point, the stub has saved the current application stack esp into AppRsp
|
||||||
|
;; and switched stacks to the debug stack, where it pushed the vector number
|
||||||
|
;;
|
||||||
|
;; The application stack looks like this:
|
||||||
|
;;
|
||||||
|
;; ...
|
||||||
|
;; (last application stack entry)
|
||||||
|
;; [16 bytes alignment, do not care it]
|
||||||
|
;; SS from interrupted task
|
||||||
|
;; RSP from interrupted task
|
||||||
|
;; rflags from interrupted task
|
||||||
|
;; CS from interrupted task
|
||||||
|
;; RIP from interrupted task
|
||||||
|
;; Error code <-------------------- Only present for some exeption types
|
||||||
|
;;
|
||||||
|
;; Vector Number <----------------- pushed in our IDT Entry
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
|
;; The stub switched us to the debug stack and pushed the interrupt number.
|
||||||
|
;;
|
||||||
|
;; Next, construct the context record. It will be build on the debug stack by
|
||||||
|
;; pushing the registers in the correct order so as to create the context structure
|
||||||
|
;; on the debug stack. The context record must be built from the end back to the
|
||||||
|
;; beginning because the stack grows down...
|
||||||
|
;
|
||||||
|
;; For reference, the context record looks like this:
|
||||||
|
;;
|
||||||
|
;; typedef
|
||||||
|
;; struct {
|
||||||
|
;; UINT64 ExceptionData;
|
||||||
|
;; FX_SAVE_STATE_X64 FxSaveState;
|
||||||
|
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||||
|
;; UINT64 Cr0, Cr2, Cr3, Cr4, Cr8;
|
||||||
|
;; UINT64 RFlags;
|
||||||
|
;; UINT64 Ldtr, Tr;
|
||||||
|
;; UINT64 Gdtr[2], Idtr[2];
|
||||||
|
;; UINT64 Rip;
|
||||||
|
;; UINT64 Gs, Fs, Es, Ds, Cs, Ss;
|
||||||
|
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
|
||||||
|
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
|
||||||
|
;; } SYSTEM_CONTEXT_X64; // 64 bit system context record
|
||||||
|
|
||||||
|
;; NOTE: we save rsp here to prevent compiler put rip reference cause error AppRsp
|
||||||
|
push rax
|
||||||
|
mov rax, qword ptr [rsp][8] ; save vector number
|
||||||
|
mov ExceptionNumber, rax ; save vector number
|
||||||
|
pop rax
|
||||||
|
add rsp, 8 ; pop vector number
|
||||||
|
mov AppRsp, rsp ; save stack top
|
||||||
|
mov rsp, offset DebugStackBegin ; switch to debugger stack
|
||||||
|
sub rsp, 8 ; leave space for vector number
|
||||||
|
|
||||||
|
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
|
||||||
|
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
|
||||||
|
push r15
|
||||||
|
push r14
|
||||||
|
push r13
|
||||||
|
push r12
|
||||||
|
push r11
|
||||||
|
push r10
|
||||||
|
push r9
|
||||||
|
push r8
|
||||||
|
push rax
|
||||||
|
push rcx
|
||||||
|
push rdx
|
||||||
|
push rbx
|
||||||
|
push rsp
|
||||||
|
push rbp
|
||||||
|
push rsi
|
||||||
|
push rdi
|
||||||
|
|
||||||
|
;; Save interrupt state rflags register...
|
||||||
|
pushfq
|
||||||
|
pop rax
|
||||||
|
mov qword ptr Rflags, rax
|
||||||
|
|
||||||
|
;; We need to determine if any extra data was pushed by the exception, and if so, save it
|
||||||
|
;; To do this, we check the exception number pushed by the stub, and cache the
|
||||||
|
;; result in a variable since we'll need this again.
|
||||||
|
cmp ExceptionNumber, EXCPT64_DOUBLE_FAULT
|
||||||
|
jz ExtraPushOne
|
||||||
|
cmp ExceptionNumber, EXCPT64_INVALID_TSS
|
||||||
|
jz ExtraPushOne
|
||||||
|
cmp ExceptionNumber, EXCPT64_SEG_NOT_PRESENT
|
||||||
|
jz ExtraPushOne
|
||||||
|
cmp ExceptionNumber, EXCPT64_STACK_FAULT
|
||||||
|
jz ExtraPushOne
|
||||||
|
cmp ExceptionNumber, EXCPT64_GP_FAULT
|
||||||
|
jz ExtraPushOne
|
||||||
|
cmp ExceptionNumber, EXCPT64_PAGE_FAULT
|
||||||
|
jz ExtraPushOne
|
||||||
|
cmp ExceptionNumber, EXCPT64_ALIGNMENT_CHECK
|
||||||
|
jz ExtraPushOne
|
||||||
|
mov ExtraPush, 0
|
||||||
|
mov ExceptData, 0
|
||||||
|
jmp ExtraPushDone
|
||||||
|
ExtraPushOne:
|
||||||
|
mov ExtraPush, 1
|
||||||
|
|
||||||
|
;; If there's some extra data, save it also, and modify the saved AppRsp to effectively
|
||||||
|
;; pop this value off the application's stack.
|
||||||
|
mov rax, AppRsp
|
||||||
|
mov rbx, [rax]
|
||||||
|
mov ExceptData, rbx
|
||||||
|
add rax, 8
|
||||||
|
mov AppRsp, rax
|
||||||
|
|
||||||
|
ExtraPushDone:
|
||||||
|
|
||||||
|
;; The "push" above pushed the debug stack rsp. Since what we're actually doing
|
||||||
|
;; is building the context record on the debug stack, we need to save the pushed
|
||||||
|
;; debug RSP, and replace it with the application's last stack entry...
|
||||||
|
mov rax, [rsp + 24]
|
||||||
|
mov DebugRsp, rax
|
||||||
|
mov rax, AppRsp
|
||||||
|
add rax, 40
|
||||||
|
; application stack has ss, rsp, rflags, cs, & rip, so
|
||||||
|
; last actual application stack entry is
|
||||||
|
; 40 bytes into the application stack.
|
||||||
|
mov [rsp + 24], rax
|
||||||
|
|
||||||
|
;; continue building context record
|
||||||
|
;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero
|
||||||
|
mov rax, ss
|
||||||
|
push rax
|
||||||
|
|
||||||
|
; CS from application is one entry back in application stack
|
||||||
|
mov rax, AppRsp
|
||||||
|
movzx rax, word ptr [rax + 8]
|
||||||
|
push rax
|
||||||
|
|
||||||
|
mov rax, ds
|
||||||
|
push rax
|
||||||
|
mov rax, es
|
||||||
|
push rax
|
||||||
|
mov rax, fs
|
||||||
|
push rax
|
||||||
|
mov rax, gs
|
||||||
|
push rax
|
||||||
|
|
||||||
|
;; UINT64 Rip;
|
||||||
|
; Rip from application is on top of application stack
|
||||||
|
mov rax, AppRsp
|
||||||
|
push qword ptr [rax]
|
||||||
|
|
||||||
|
;; UINT64 Gdtr[2], Idtr[2];
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
sidt fword ptr [rsp]
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
sgdt fword ptr [rsp]
|
||||||
|
|
||||||
|
;; UINT64 Ldtr, Tr;
|
||||||
|
xor rax, rax
|
||||||
|
str ax
|
||||||
|
push rax
|
||||||
|
sldt ax
|
||||||
|
push rax
|
||||||
|
|
||||||
|
;; UINT64 RFlags;
|
||||||
|
;; Rflags from application is two entries back in application stack
|
||||||
|
mov rax, AppRsp
|
||||||
|
push qword ptr [rax + 16]
|
||||||
|
|
||||||
|
;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8;
|
||||||
|
;; insure FXSAVE/FXRSTOR is enabled in CR4...
|
||||||
|
;; ... while we're at it, make sure DE is also enabled...
|
||||||
|
mov rax, cr8
|
||||||
|
push rax
|
||||||
|
mov rax, cr4
|
||||||
|
or rax, 208h
|
||||||
|
mov cr4, rax
|
||||||
|
push rax
|
||||||
|
mov rax, cr3
|
||||||
|
push rax
|
||||||
|
mov rax, cr2
|
||||||
|
push rax
|
||||||
|
push 0
|
||||||
|
mov rax, cr0
|
||||||
|
push rax
|
||||||
|
|
||||||
|
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||||
|
mov rax, dr7
|
||||||
|
push rax
|
||||||
|
;; clear Dr7 while executing debugger itself
|
||||||
|
xor rax, rax
|
||||||
|
mov dr7, rax
|
||||||
|
|
||||||
|
mov rax, dr6
|
||||||
|
push rax
|
||||||
|
;; insure all status bits in dr6 are clear...
|
||||||
|
xor rax, rax
|
||||||
|
mov dr6, rax
|
||||||
|
|
||||||
|
mov rax, dr3
|
||||||
|
push rax
|
||||||
|
mov rax, dr2
|
||||||
|
push rax
|
||||||
|
mov rax, dr1
|
||||||
|
push rax
|
||||||
|
mov rax, dr0
|
||||||
|
push rax
|
||||||
|
|
||||||
|
;; FX_SAVE_STATE_X64 FxSaveState;
|
||||||
|
sub rsp, 512
|
||||||
|
mov rdi, rsp
|
||||||
|
; IMPORTANT!! The debug stack has been carefully constructed to
|
||||||
|
; insure that rsp and rdi are 16 byte aligned when we get here.
|
||||||
|
; They MUST be. If they are not, a GP fault will occur.
|
||||||
|
FXSTOR_RDI
|
||||||
|
|
||||||
|
;; UINT64 ExceptionData;
|
||||||
|
mov rax, ExceptData
|
||||||
|
push rax
|
||||||
|
|
||||||
|
; call to C code which will in turn call registered handler
|
||||||
|
; pass in the vector number
|
||||||
|
mov rdx, rsp
|
||||||
|
mov rcx, ExceptionNumber
|
||||||
|
sub rsp, 40
|
||||||
|
call InterruptDistrubutionHub
|
||||||
|
add rsp, 40
|
||||||
|
|
||||||
|
; restore context...
|
||||||
|
;; UINT64 ExceptionData;
|
||||||
|
add rsp, 8
|
||||||
|
|
||||||
|
;; FX_SAVE_STATE_X64 FxSaveState;
|
||||||
|
mov rsi, rsp
|
||||||
|
FXRSTOR_RSI
|
||||||
|
add rsp, 512
|
||||||
|
|
||||||
|
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||||
|
pop rax
|
||||||
|
mov dr0, rax
|
||||||
|
pop rax
|
||||||
|
mov dr1, rax
|
||||||
|
pop rax
|
||||||
|
mov dr2, rax
|
||||||
|
pop rax
|
||||||
|
mov dr3, rax
|
||||||
|
;; skip restore of dr6. We cleared dr6 during the context save.
|
||||||
|
add rsp, 8
|
||||||
|
pop rax
|
||||||
|
mov dr7, rax
|
||||||
|
|
||||||
|
;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8;
|
||||||
|
pop rax
|
||||||
|
mov cr0, rax
|
||||||
|
add rsp, 8
|
||||||
|
pop rax
|
||||||
|
mov cr2, rax
|
||||||
|
pop rax
|
||||||
|
mov cr3, rax
|
||||||
|
pop rax
|
||||||
|
mov cr4, rax
|
||||||
|
pop rax
|
||||||
|
mov cr8, rax
|
||||||
|
|
||||||
|
;; UINT64 RFlags;
|
||||||
|
mov rax, AppRsp
|
||||||
|
pop qword ptr [rax + 16]
|
||||||
|
|
||||||
|
;; UINT64 Ldtr, Tr;
|
||||||
|
;; UINT64 Gdtr[2], Idtr[2];
|
||||||
|
;; Best not let anyone mess with these particular registers...
|
||||||
|
add rsp, 48
|
||||||
|
|
||||||
|
;; UINT64 Rip;
|
||||||
|
pop qword ptr [rax]
|
||||||
|
|
||||||
|
;; UINT64 Gs, Fs, Es, Ds, Cs, Ss;
|
||||||
|
;; NOTE - modified segment registers could hang the debugger... We
|
||||||
|
;; could attempt to insulate ourselves against this possibility,
|
||||||
|
;; but that poses risks as well.
|
||||||
|
;;
|
||||||
|
|
||||||
|
pop rax
|
||||||
|
; mov gs, rax
|
||||||
|
pop rax
|
||||||
|
; mov fs, rax
|
||||||
|
pop rax
|
||||||
|
mov es, rax
|
||||||
|
pop rax
|
||||||
|
mov ds, rax
|
||||||
|
mov rax, AppRsp
|
||||||
|
pop qword ptr [rax + 8]
|
||||||
|
pop rax
|
||||||
|
mov ss, rax
|
||||||
|
|
||||||
|
;; The next stuff to restore is the general purpose registers that were pushed
|
||||||
|
;; using the "push" instruction.
|
||||||
|
;;
|
||||||
|
;; The value of RSP as stored in the context record is the application RSP
|
||||||
|
;; including the 5 entries on the application stack caused by the exception
|
||||||
|
;; itself. It may have been modified by the debug agent, so we need to
|
||||||
|
;; determine if we need to relocate the application stack.
|
||||||
|
|
||||||
|
mov rbx, [rsp + 24] ; move the potentially modified AppRsp into rbx
|
||||||
|
mov rax, AppRsp
|
||||||
|
add rax, 40
|
||||||
|
cmp rbx, rax
|
||||||
|
je NoAppStackMove
|
||||||
|
|
||||||
|
mov rax, AppRsp
|
||||||
|
mov rcx, [rax] ; RIP
|
||||||
|
mov [rbx], rcx
|
||||||
|
|
||||||
|
mov rcx, [rax + 8] ; CS
|
||||||
|
mov [rbx + 8], rcx
|
||||||
|
|
||||||
|
mov rcx, [rax + 16] ; RFLAGS
|
||||||
|
mov [rbx + 16], rcx
|
||||||
|
|
||||||
|
mov rcx, [rax + 24] ; RSP
|
||||||
|
mov [rbx + 24], rcx
|
||||||
|
|
||||||
|
mov rcx, [rax + 32] ; SS
|
||||||
|
mov [rbx + 32], rcx
|
||||||
|
|
||||||
|
mov rax, rbx ; modify the saved AppRsp to the new AppRsp
|
||||||
|
mov AppRsp, rax
|
||||||
|
NoAppStackMove:
|
||||||
|
mov rax, DebugRsp ; restore the DebugRsp on the debug stack
|
||||||
|
; so our "pop" will not cause a stack switch
|
||||||
|
mov [rsp + 24], rax
|
||||||
|
|
||||||
|
cmp ExceptionNumber, 068h
|
||||||
|
jne NoChain
|
||||||
|
|
||||||
|
Chain:
|
||||||
|
|
||||||
|
;; Restore rflags so when we chain, the flags will be exactly as if we were never here.
|
||||||
|
;; We gin up the stack to do an iretq so we can get ALL the flags.
|
||||||
|
mov rax, AppRsp
|
||||||
|
mov rbx, [rax + 40]
|
||||||
|
push rbx
|
||||||
|
mov rax, ss
|
||||||
|
push rax
|
||||||
|
mov rax, rsp
|
||||||
|
add rax, 16
|
||||||
|
push rax
|
||||||
|
mov rax, AppRsp
|
||||||
|
mov rbx, [rax + 16]
|
||||||
|
and rbx, NOT 300h ; special handling for IF and TF
|
||||||
|
push rbx
|
||||||
|
mov rax, cs
|
||||||
|
push rax
|
||||||
|
mov rax, offset PhonyIretq
|
||||||
|
push rax
|
||||||
|
iretq
|
||||||
|
PhonyIretq:
|
||||||
|
|
||||||
|
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
|
||||||
|
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
|
||||||
|
pop rdi
|
||||||
|
pop rsi
|
||||||
|
pop rbp
|
||||||
|
pop rsp
|
||||||
|
pop rbx
|
||||||
|
pop rdx
|
||||||
|
pop rcx
|
||||||
|
pop rax
|
||||||
|
pop r8
|
||||||
|
pop r9
|
||||||
|
pop r10
|
||||||
|
pop r11
|
||||||
|
pop r12
|
||||||
|
pop r13
|
||||||
|
pop r14
|
||||||
|
pop r15
|
||||||
|
|
||||||
|
;; Switch back to application stack
|
||||||
|
mov rsp, AppRsp
|
||||||
|
|
||||||
|
;; Jump to original handler
|
||||||
|
jmp OrigVector
|
||||||
|
|
||||||
|
NoChain:
|
||||||
|
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
|
||||||
|
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
|
||||||
|
pop rdi
|
||||||
|
pop rsi
|
||||||
|
pop rbp
|
||||||
|
pop rsp
|
||||||
|
pop rbx
|
||||||
|
pop rdx
|
||||||
|
pop rcx
|
||||||
|
pop rax
|
||||||
|
pop r8
|
||||||
|
pop r9
|
||||||
|
pop r10
|
||||||
|
pop r11
|
||||||
|
pop r12
|
||||||
|
pop r13
|
||||||
|
pop r14
|
||||||
|
pop r15
|
||||||
|
|
||||||
|
;; Switch back to application stack
|
||||||
|
mov rsp, AppRsp
|
||||||
|
|
||||||
|
;; We're outa here...
|
||||||
|
iretq
|
||||||
|
text ENDS
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
|
437
EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c
Normal file
437
EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c
Normal file
@ -0,0 +1,437 @@
|
|||||||
|
/**@file
|
||||||
|
X64 specific debug support functions
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
//
|
||||||
|
// private header files
|
||||||
|
//
|
||||||
|
#include "plDebugSupport.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// This the global main table to keep track of the interrupts
|
||||||
|
//
|
||||||
|
IDT_ENTRY *IdtEntryTable = NULL;
|
||||||
|
DESCRIPTOR NullDesc = {0, 0};
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
CreateEntryStub (
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
|
OUT VOID **Stub
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: Allocate pool for a new IDT entry stub. Copy the generic
|
||||||
|
stub into the new buffer and fixup the vector number and jump target address.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ExceptionType - This is the exception type that the new stub will be created
|
||||||
|
for.
|
||||||
|
Stub - On successful exit, *Stub contains the newly allocated entry stub.
|
||||||
|
Returns:
|
||||||
|
Typically EFI_SUCCESS
|
||||||
|
other possibilities are passed through from AllocatePool
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT8 *StubCopy;
|
||||||
|
|
||||||
|
//
|
||||||
|
// First, allocate a new buffer and copy the stub code into it
|
||||||
|
//
|
||||||
|
Status = gBS->AllocatePool (EfiBootServicesData, StubSize, Stub);
|
||||||
|
if (Status == EFI_SUCCESS) {
|
||||||
|
StubCopy = *Stub;
|
||||||
|
gBS->CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Next fixup the stub code for this vector
|
||||||
|
//
|
||||||
|
|
||||||
|
// The stub code looks like this:
|
||||||
|
//
|
||||||
|
// 00000000 6A 00 push 0 ; push vector number - will be modified before installed
|
||||||
|
// 00000002 E9 db 0e9h ; jump rel32
|
||||||
|
// 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// poke in the exception type so the second push pushes the exception type
|
||||||
|
//
|
||||||
|
StubCopy[0x1] = (UINT8) ExceptionType;
|
||||||
|
|
||||||
|
//
|
||||||
|
// fixup the jump target to point to the common entry
|
||||||
|
//
|
||||||
|
*(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
HookEntry (
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
|
IN VOID (*NewCallback) ()
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Creates a nes entry stub. Then saves the current IDT entry and replaces it
|
||||||
|
with an interrupt gate for the new entry point. The IdtEntryTable is updated
|
||||||
|
with the new registered function.
|
||||||
|
|
||||||
|
This code executes in boot services context. The stub entry executes in interrupt
|
||||||
|
context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ExceptionType - specifies which vector to hook.
|
||||||
|
NewCallback - a pointer to the new function to be registered.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
|
Other possibilities are passed through by CreateEntryStub
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
BOOLEAN OldIntFlagState;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = CreateEntryStub (ExceptionType, (VOID **) &IdtEntryTable[ExceptionType].StubEntry);
|
||||||
|
if (Status == EFI_SUCCESS) {
|
||||||
|
OldIntFlagState = WriteInterruptFlag (0);
|
||||||
|
ReadIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
|
||||||
|
|
||||||
|
((UINT16 *) &IdtEntryTable[ExceptionType].OrigVector)[0] = ((UINT16 *) &IdtEntryTable[ExceptionType].OrigDesc.Low)[0];
|
||||||
|
((UINT16 *) &IdtEntryTable[ExceptionType].OrigVector)[1] = ((UINT16 *) &IdtEntryTable[ExceptionType].OrigDesc.Low)[3];
|
||||||
|
((UINT32 *) &IdtEntryTable[ExceptionType].OrigVector)[1] = ((UINT32 *) &IdtEntryTable[ExceptionType].OrigDesc.High)[0];
|
||||||
|
|
||||||
|
Vect2Desc (&IdtEntryTable[ExceptionType].NewDesc, IdtEntryTable[ExceptionType].StubEntry);
|
||||||
|
IdtEntryTable[ExceptionType].RegisteredCallback = NewCallback;
|
||||||
|
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));
|
||||||
|
WriteInterruptFlag (OldIntFlagState);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
UnhookEntry (
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Undoes HookEntry. This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ExceptionType - specifies which entry to unhook
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
|
Other values are passed through from FreePool
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
BOOLEAN OldIntFlagState;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
OldIntFlagState = WriteInterruptFlag (0);
|
||||||
|
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
|
||||||
|
Status = gBS->FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||||
|
ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
|
||||||
|
WriteInterruptFlag (OldIntFlagState);
|
||||||
|
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
ManageIdtEntryTable (
|
||||||
|
VOID (*NewCallback)(),
|
||||||
|
EFI_EXCEPTION_TYPE ExceptionType
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is the main worker function that manages the state of the interrupt
|
||||||
|
handlers. It both installs and uninstalls interrupt handlers based on the
|
||||||
|
value of NewCallback. If NewCallback is NULL, then uninstall is indicated.
|
||||||
|
If NewCallback is non-NULL, then install is indicated.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
NewCallback - If non-NULL, NewCallback specifies the new handler to register.
|
||||||
|
If NULL, specifies that the previously registered handler should
|
||||||
|
be uninstalled.
|
||||||
|
ExceptionType - Indicates which entry to manage
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
if (CompareDescriptor (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {
|
||||||
|
//
|
||||||
|
// we've already installed to this vector
|
||||||
|
//
|
||||||
|
if (NewCallback != NULL) {
|
||||||
|
//
|
||||||
|
// if the input handler is non-null, error
|
||||||
|
//
|
||||||
|
Status = EFI_ALREADY_STARTED;
|
||||||
|
} else {
|
||||||
|
Status = UnhookEntry (ExceptionType);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// no user handler installed on this vector
|
||||||
|
//
|
||||||
|
if (NewCallback == NULL) {
|
||||||
|
//
|
||||||
|
// if the input handler is null, error
|
||||||
|
//
|
||||||
|
Status = EFI_INVALID_PARAMETER;
|
||||||
|
} else {
|
||||||
|
Status = HookEntry (ExceptionType, NewCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetMaximumProcessorIndex (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
OUT UINTN *MaxProcessorIndex
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
MaxProcessorIndex - The maximuim supported processor index
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
*MaxProcessorIndex = 0;
|
||||||
|
return (EFI_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterPeriodicCallback (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN EFI_PERIODIC_CALLBACK PeriodicCallback
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
PeriodicCallback - Callback function
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterExceptionCallback (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN EFI_EXCEPTION_CALLBACK NewCallback,
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
|
This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
NewCallback - Callback function
|
||||||
|
ExceptionType - Which exception to hook
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
return ManageIdtEntryTable (NewCallback, ExceptionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InvalidateInstructionCache (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN VOID *Start,
|
||||||
|
IN UINT64 Length
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is a DebugSupport protocol member function.
|
||||||
|
Calls assembly routine to flush cache.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
Start - Physical base of the memory range to be invalidated
|
||||||
|
Length - mininum number of bytes in instruction cache to invalidate
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
AsmWbinvd ();
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
plInitializeDebugSupportDriver (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Initializes driver's handler registration database.
|
||||||
|
|
||||||
|
This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_UNSUPPORTED - if X64 processor does not support FXSTOR/FXRSTOR instructions,
|
||||||
|
the context save will fail, so these processor's are not supported.
|
||||||
|
EFI_OUT_OF_RESOURCES - not resource to finish initialization
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
if (!FxStorSupport ()) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
} else {
|
||||||
|
IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
|
||||||
|
if (IdtEntryTable != NULL) {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
plUnloadDebugSupportDriver (
|
||||||
|
IN EFI_HANDLE ImageHandle
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is the callback that is written to the LoadedImage protocol instance
|
||||||
|
on the image handle. It uninstalls all registered handlers and frees all entry
|
||||||
|
stub memory.
|
||||||
|
|
||||||
|
This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ImageHandle - The image handle of the unload handler
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
EFI_EXCEPTION_TYPE ExceptionType;
|
||||||
|
|
||||||
|
for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
|
||||||
|
ManageIdtEntryTable (NULL, ExceptionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
gBS->FreePool (IdtEntryTable);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
InterruptDistrubutionHub (
|
||||||
|
EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
|
EFI_SYSTEM_CONTEXT_IA32 *ContextRecord
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: Common piece of code that invokes the registered handlers.
|
||||||
|
|
||||||
|
This code executes in exception context so no efi calls are allowed.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ExceptionType - exception type
|
||||||
|
ContextRecord - system context
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {
|
||||||
|
if (ExceptionType != SYSTEM_TIMER_VECTOR) {
|
||||||
|
IdtEntryTable[ExceptionType].RegisteredCallback (ExceptionType, ContextRecord);
|
||||||
|
} else {
|
||||||
|
OrigVector = IdtEntryTable[ExceptionType].OrigVector;
|
||||||
|
IdtEntryTable[ExceptionType].RegisteredCallback (ContextRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
315
EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h
Normal file
315
EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.h
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
/**@file
|
||||||
|
X64 specific debug support macros, typedefs and prototypes.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _PLDEBUG_SUPPORT_H
|
||||||
|
#define _PLDEBUG_SUPPORT_H
|
||||||
|
|
||||||
|
#define NUM_IDT_ENTRIES 0x78
|
||||||
|
#define SYSTEM_TIMER_VECTOR 0x68
|
||||||
|
#define VECTOR_ENTRY_PAGES 1
|
||||||
|
#define CopyDescriptor(Dest, Src) CopyMem ((Dest), (Src), sizeof (DESCRIPTOR))
|
||||||
|
#define ZeroDescriptor(Dest) CopyDescriptor ((Dest), &NullDesc)
|
||||||
|
#define ReadIdt(Vector, Dest) CopyDescriptor ((Dest), &((GetIdtr ())[(Vector)]))
|
||||||
|
#define WriteIdt(Vector, Src) CopyDescriptor (&((GetIdtr ())[(Vector)]), (Src))
|
||||||
|
#define CompareDescriptor(Desc1, Desc2) CompareMem ((Desc1), (Desc2), sizeof (DESCRIPTOR))
|
||||||
|
#define EFI_ISA IsaX64
|
||||||
|
#define FF_FXSR (1 << 24)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT64 Low;
|
||||||
|
UINT64 High;
|
||||||
|
} DESCRIPTOR;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DESCRIPTOR OrigDesc;
|
||||||
|
VOID (*OrigVector) (VOID);
|
||||||
|
DESCRIPTOR NewDesc;
|
||||||
|
VOID (*StubEntry) (VOID);
|
||||||
|
VOID (*RegisteredCallback) ();
|
||||||
|
} IDT_ENTRY;
|
||||||
|
|
||||||
|
extern EFI_SYSTEM_CONTEXT SystemContext;
|
||||||
|
extern UINT8 InterruptEntryStub[];
|
||||||
|
extern UINT32 StubSize;
|
||||||
|
extern VOID (*OrigVector) (VOID);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
CommonIdtEntry (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Generic IDT entry
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
FxStorSupport (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Check whether FXSTOR is supported
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
TRUE - supported
|
||||||
|
FALSE - not supported
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
DESCRIPTOR *
|
||||||
|
GetIdtr (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Return the physical address of IDTR
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
The physical address of IDTR
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
Vect2Desc (
|
||||||
|
DESCRIPTOR * DestDesc,
|
||||||
|
VOID (*Vector) (VOID)
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Encodes an IDT descriptor with the given physical address
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
DestDesc - The IDT descriptor address
|
||||||
|
Vector - The interrupt vector entry
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
WriteInterruptFlag (
|
||||||
|
BOOLEAN NewState
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Programs interrupt flag to the requested state and returns previous
|
||||||
|
state.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
NewState - New interrupt status
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Old interrupt status
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
plInitializeDebugSupportDriver (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
Initializes driver's handler registration database.
|
||||||
|
|
||||||
|
This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_UNSUPPORTED - if X64 processor does not support FXSTOR/FXRSTOR instructions,
|
||||||
|
the context save will fail, so these processor's are not supported.
|
||||||
|
EFI_OUT_OF_RESOURCES - not resource to finish initialization
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
plUnloadDebugSupportDriver (
|
||||||
|
IN EFI_HANDLE ImageHandle
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is the callback that is written to the LoadedImage protocol instance
|
||||||
|
on the image handle. It uninstalls all registered handlers and frees all entry
|
||||||
|
stub memory.
|
||||||
|
|
||||||
|
This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
ImageHandle - The image handle of the unload handler
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// DebugSupport protocol member functions
|
||||||
|
//
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
GetMaximumProcessorIndex (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
OUT UINTN *MaxProcessorIndex
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
MaxProcessorIndex - The maximuim supported processor index
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterPeriodicCallback (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN EFI_PERIODIC_CALLBACK PeriodicCallback
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description: This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
PeriodicCallback - Callback function
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterExceptionCallback (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN EFI_EXCEPTION_CALLBACK NewCallback,
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is a DebugSupport protocol member function.
|
||||||
|
|
||||||
|
This code executes in boot services context.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
NewCallback - Callback function
|
||||||
|
ExceptionType - Which exception to hook
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS
|
||||||
|
EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
|
||||||
|
no handler registered for it
|
||||||
|
EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
|
||||||
|
|
||||||
|
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InvalidateInstructionCache (
|
||||||
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
||||||
|
IN UINTN ProcessorIndex,
|
||||||
|
IN VOID *Start,
|
||||||
|
IN UINT64 Length
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
This is a DebugSupport protocol member function.
|
||||||
|
Calls assembly routine to flush cache.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
This - The DebugSupport instance
|
||||||
|
ProcessorIndex - Which processor the callback applies to.
|
||||||
|
Start - Physical base of the memory range to be invalidated
|
||||||
|
Length - mininum number of bytes in instruction cache to invalidate
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - always return success
|
||||||
|
|
||||||
|
--*/
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user