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:
@@ -79,16 +79,16 @@ OrigVector dd 66666666h ; ?
|
||||
;;
|
||||
;; For reference, the context structure looks like this:
|
||||
;; struct {
|
||||
;; UINT32 ExceptionData;
|
||||
;; FX_SAVE_STATE FxSaveState; // 512 bytes, must be 16 byte aligned
|
||||
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||
;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
|
||||
;; UINT32 Ldtr, Tr;
|
||||
;; UINT64 Gdtr, Idtr;
|
||||
;; UINT32 EFlags;
|
||||
;; UINT32 Eip;
|
||||
;; UINT32 SegGs, SegFs, SegEs, SegDs, SegCs, SegSs;
|
||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||
;; UINT32 ExceptionData;
|
||||
;; FX_SAVE_STATE_IA32 FxSaveState; // 512 bytes, must be 16 byte aligned
|
||||
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||
;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
|
||||
;; UINT32 EFlags;
|
||||
;; UINT32 Ldtr, Tr;
|
||||
;; UINT32 Gdtr[2], Idtr[2];
|
||||
;; UINT32 Eip;
|
||||
;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
|
||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record
|
||||
|
||||
|
||||
@@ -208,11 +208,11 @@ Vect2Desc ENDP
|
||||
; copied and fixed up once for each IDT entry that is hooked.
|
||||
;
|
||||
InterruptEntryStub::
|
||||
mov AppEsp, esp ; save stack top
|
||||
mov AppEsp, esp ; save stack top
|
||||
mov esp, offset DebugStackBegin ; switch to debugger stack
|
||||
push 0 ; push vector number - will be modified before installed
|
||||
db 0e9h ; jump rel32
|
||||
dd 0 ; fixed up to relative address of CommonIdtEntry
|
||||
push 0 ; push vector number - will be modified before installed
|
||||
db 0e9h ; jump rel32
|
||||
dd 0 ; fixed up to relative address of CommonIdtEntry
|
||||
InterruptEntryStubEnd:
|
||||
|
||||
|
||||
@@ -251,16 +251,16 @@ CommonIdtEntry::
|
||||
;;
|
||||
;; typedef
|
||||
;; struct {
|
||||
;; UINT32 ExceptionData;
|
||||
;; FX_SAVE_STATE FxSaveState;
|
||||
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||
;; UINT32 Cr0, Cr2, Cr3, Cr4;
|
||||
;; UINT32 Ldtr, Tr;
|
||||
;; UINT64 Gdtr, Idtr;
|
||||
;; UINT32 EFlags;
|
||||
;; UINT32 Eip;
|
||||
;; UINT32 SegGs, SegFs, SegEs, SegDs, SegCs, SegSs;
|
||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||
;; UINT32 ExceptionData;
|
||||
;; FX_SAVE_STATE_IA32 FxSaveState;
|
||||
;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
|
||||
;; UINT32 Cr0, Cr2, Cr3, Cr4;
|
||||
;; UINT32 EFlags;
|
||||
;; UINT32 Ldtr, Tr;
|
||||
;; UINT32 Gdtr[2], Idtr[2];
|
||||
;; UINT32 Eip;
|
||||
;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
|
||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record
|
||||
|
||||
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
|
||||
@@ -340,7 +340,7 @@ CommonIdtEntry::
|
||||
mov eax, AppEsp
|
||||
push dword ptr [eax]
|
||||
|
||||
;; UINT64 Gdtr, Idtr;
|
||||
;; UINT32 Gdtr[2], Idtr[2];
|
||||
push 0
|
||||
push 0
|
||||
sidt fword ptr [esp]
|
||||
@@ -397,7 +397,7 @@ CommonIdtEntry::
|
||||
mov eax, dr0
|
||||
push eax
|
||||
|
||||
;; FX_SAVE_STATE FxSaveState;
|
||||
;; FX_SAVE_STATE_IA32 FxSaveState;
|
||||
sub esp, 512
|
||||
mov edi, esp
|
||||
; IMPORTANT!! The debug stack has been carefully constructed to
|
||||
@@ -422,7 +422,7 @@ CommonIdtEntry::
|
||||
;; UINT32 ExceptionData;
|
||||
add esp, 4
|
||||
|
||||
;; FX_SAVE_STATE FxSaveState;
|
||||
;; FX_SAVE_STATE_IA32 FxSaveState;
|
||||
mov esi, esp
|
||||
FXRSTOR_ESI
|
||||
add esp, 512
|
||||
@@ -456,8 +456,8 @@ CommonIdtEntry::
|
||||
mov eax, AppEsp
|
||||
pop dword ptr [eax + 8]
|
||||
|
||||
;; UINT16 Ldtr, Tr;
|
||||
;; UINT64 Gdtr, Idtr;
|
||||
;; UINT32 Ldtr, Tr;
|
||||
;; UINT32 Gdtr[2], Idtr[2];
|
||||
;; Best not let anyone mess with these particular registers...
|
||||
add esp, 24
|
||||
|
||||
@@ -478,7 +478,7 @@ CommonIdtEntry::
|
||||
pop ss
|
||||
|
||||
;; 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
|
||||
;; including the 3 entries on the application stack caused by the exception
|
||||
@@ -505,7 +505,7 @@ CommonIdtEntry::
|
||||
mov AppEsp, eax
|
||||
NoAppStackMove:
|
||||
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
|
||||
|
||||
cmp ExceptionNumber, 068h
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
/**@file
|
||||
IA32 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
|
||||
@@ -9,17 +10,7 @@ http://opensource.org/licenses/bsd-license.php
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
plDebugSupport.c
|
||||
|
||||
Abstract:
|
||||
|
||||
IA32 specific debug support functions
|
||||
|
||||
Revision History
|
||||
|
||||
--*/
|
||||
**/
|
||||
|
||||
//
|
||||
// private header files
|
||||
@@ -117,7 +108,6 @@ Returns:
|
||||
Other possibilities are passed through by CreateEntryStub
|
||||
|
||||
--*/
|
||||
// TODO: ) - add argument and description to function comment
|
||||
{
|
||||
BOOLEAN OldIntFlagState;
|
||||
EFI_STATUS Status;
|
||||
@@ -199,7 +189,6 @@ Returns:
|
||||
Other possible return values are passed through from UnHookEntry and HookEntry.
|
||||
|
||||
--*/
|
||||
// TODO: ) - add argument and description to function comment
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
@@ -246,12 +235,13 @@ GetMaximumProcessorIndex (
|
||||
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
|
||||
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;
|
||||
return (EFI_SUCCESS);
|
||||
@@ -269,13 +259,20 @@ RegisterPeriodicCallback (
|
||||
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.
|
||||
|
||||
--*/
|
||||
// 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);
|
||||
}
|
||||
@@ -296,16 +293,21 @@ Routine Description:
|
||||
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:
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -322,21 +324,21 @@ InvalidateInstructionCache (
|
||||
|
||||
Routine Description:
|
||||
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:
|
||||
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:
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -358,9 +360,9 @@ Returns:
|
||||
EFI_SUCCESS
|
||||
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
|
||||
|
||||
--*/
|
||||
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
|
||||
{
|
||||
if (!FxStorSupport ()) {
|
||||
return EFI_UNSUPPORTED;
|
||||
@@ -393,10 +395,9 @@ Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
EFI_SUCCESS - always return success
|
||||
|
||||
--*/
|
||||
// TODO: EFI_SUCCESS - add return value to function comment
|
||||
{
|
||||
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.
|
||||
|
||||
Arguments:
|
||||
ExceptionType - exception type
|
||||
ContextRecord - system context
|
||||
|
||||
Returns:
|
||||
|
||||
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 (ExceptionType != SYSTEM_TIMER_VECTOR) {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
/*++
|
||||
/**@file
|
||||
IA32 specific debug support macros, typedefs and prototypes.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
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,
|
||||
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
|
||||
#define _PLDEBUG_SUPPORT_H
|
||||
@@ -58,7 +49,7 @@ CommonIdtEntry (
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Generic IDT entry
|
||||
|
||||
Arguments:
|
||||
|
||||
@@ -66,11 +57,12 @@ Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
|
||||
BOOLEAN
|
||||
FxStorSupport (
|
||||
VOID
|
||||
@@ -79,7 +71,7 @@ FxStorSupport (
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Check whether FXSTOR is supported
|
||||
|
||||
Arguments:
|
||||
|
||||
@@ -87,7 +79,8 @@ Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
TRUE - supported
|
||||
FALSE - not supported
|
||||
|
||||
--*/
|
||||
;
|
||||
@@ -100,7 +93,7 @@ GetIdtr (
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Return the physical address of IDTR
|
||||
|
||||
Arguments:
|
||||
|
||||
@@ -108,7 +101,7 @@ Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
The physical address of IDTR
|
||||
|
||||
--*/
|
||||
;
|
||||
@@ -122,16 +115,16 @@ Vect2Desc (
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Encodes an IDT descriptor with the given physical address
|
||||
|
||||
Arguments:
|
||||
|
||||
DestDesc - TODO: add argument description
|
||||
) - TODO: add argument description
|
||||
DestDesc - The IDT descriptor address
|
||||
Vector - The interrupt vector entry
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
@@ -144,15 +137,16 @@ WriteInterruptFlag (
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Programs interrupt flag to the requested state and returns previous
|
||||
state.
|
||||
|
||||
Arguments:
|
||||
|
||||
NewState - TODO: add argument description
|
||||
NewState - New interrupt status
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
Old interrupt status
|
||||
|
||||
--*/
|
||||
;
|
||||
@@ -164,16 +158,18 @@ plInitializeDebugSupportDriver (
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Initializes driver's handler registration database.
|
||||
|
||||
TODO: Add function description
|
||||
This code executes in boot services context.
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
EFI_SUCCESS
|
||||
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:
|
||||
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:
|
||||
|
||||
ImageHandle - TODO: add argument description
|
||||
ImageHandle - The image handle of the unload handler
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
EFI_SUCCESS - always return success
|
||||
|
||||
--*/
|
||||
;
|
||||
@@ -211,18 +209,14 @@ GetMaximumProcessorIndex (
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Routine Description: This is a DebugSupport protocol member function.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - TODO: add argument description
|
||||
MaxProcessorIndex - TODO: add argument description
|
||||
This - The DebugSupport instance
|
||||
MaxProcessorIndex - The maximuim supported processor index
|
||||
|
||||
Returns:
|
||||
|
||||
TODO: add return values
|
||||
Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
|
||||
|
||||
--*/
|
||||
;
|
||||
@@ -236,19 +230,21 @@ RegisterPeriodicCallback (
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
TODO: Add function description
|
||||
Routine Description: This is a DebugSupport protocol member function.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - TODO: add argument description
|
||||
ProcessorIndex - TODO: add argument description
|
||||
PeriodicCallback - TODO: add argument description
|
||||
This - The DebugSupport instance
|
||||
ProcessorIndex - Which processor the callback applies to.
|
||||
PeriodicCallback - Callback function
|
||||
|
||||
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:
|
||||
This is a DebugSupport protocol member function.
|
||||
|
||||
TODO: Add function description
|
||||
This code executes in boot services context.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - TODO: add argument description
|
||||
ProcessorIndex - TODO: add argument description
|
||||
NewCallback - TODO: add argument description
|
||||
ExceptionType - TODO: add argument description
|
||||
This - The DebugSupport instance
|
||||
ProcessorIndex - Which processor the callback applies to.
|
||||
NewCallback - Callback function
|
||||
ExceptionType - Which exception to hook
|
||||
|
||||
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:
|
||||
|
||||
TODO: Add function description
|
||||
This is a DebugSupport protocol member function.
|
||||
Calls assembly routine to flush cache.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - TODO: add argument description
|
||||
ProcessorIndex - TODO: add argument description
|
||||
Start - TODO: add argument description
|
||||
Length - TODO: add argument description
|
||||
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:
|
||||
|
||||
TODO: add return values
|
||||
EFI_SUCCESS - always return success
|
||||
|
||||
--*/
|
||||
;
|
||||
|
Reference in New Issue
Block a user