MdeModulePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdeModulePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:02 -08:00
committed by mergify[bot]
parent 7c7184e201
commit 1436aea4d5
994 changed files with 107608 additions and 101311 deletions

View File

@ -31,7 +31,7 @@ PrintUsage (
L"usage: EdbCfg <Command>\n"
L" CommandList:\n"
L" BO[C|CX|R|E|T|K] <ON|OFF> - Enable/Disable BOC/BOCX/BOR/BOE/BOT/BOK.\n"
// L" SHOWINFO - Show Debugger Information.\n"
// L" SHOWINFO - Show Debugger Information.\n"
L"\n"
);
return;
@ -46,11 +46,11 @@ PrintUsage (
**/
VOID
EdbShowInfo (
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration
)
{
Print (L"Not supported!\n");
return ;
return;
}
/**
@ -64,12 +64,12 @@ EdbShowInfo (
**/
VOID
EdbConfigBreak (
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration,
CHAR16 *Command,
CHAR16 *CommandArg
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration,
CHAR16 *Command,
CHAR16 *CommandArg
)
{
EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate;
EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate;
DebuggerPrivate = (EFI_DEBUGGER_PRIVATE_DATA *)DebuggerConfiguration->DebuggerPrivateData;
@ -158,7 +158,8 @@ EdbConfigBreak (
Print (L"Invalid parameter\n");
}
}
return ;
return;
}
/**
@ -178,18 +179,18 @@ InitializeEbcDebuggerConfig (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
UINTN Argc;
CHAR16 **Argv;
EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration;
EFI_STATUS Status;
UINTN Argc;
CHAR16 **Argv;
EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration;
EFI_STATUS Status;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiShellParametersProtocolGuid,
(VOID**)&ShellParameters
(VOID **)&ShellParameters
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
Print (L"Please use UEFI Shell to run this application.\n");
return EFI_INVALID_PARAMETER;
}
@ -206,18 +207,19 @@ InitializeEbcDebuggerConfig (
if ((StrCmp (Argv[1], L"/?") == 0) ||
(StrCmp (Argv[1], L"-?") == 0) ||
(StrCmp (Argv[1], L"-h") == 0) ||
(StrCmp (Argv[1], L"-H") == 0) ) {
(StrCmp (Argv[1], L"-H") == 0))
{
PrintUsage ();
return EFI_SUCCESS;
}
}
Status = gBS->LocateProtocol (
&gEfiDebuggerConfigurationProtocolGuid,
NULL,
(VOID**)&DebuggerConfiguration
);
if (EFI_ERROR(Status)) {
&gEfiDebuggerConfigurationProtocolGuid,
NULL,
(VOID **)&DebuggerConfiguration
);
if (EFI_ERROR (Status)) {
Print (L"Error: DebuggerConfiguration protocol not found.\n");
return EFI_NOT_FOUND;
}
@ -233,12 +235,14 @@ InitializeEbcDebuggerConfig (
(StriCmp (Argv[1], L"BOR") == 0) ||
(StriCmp (Argv[1], L"BOE") == 0) ||
(StriCmp (Argv[1], L"BOT") == 0) ||
(StriCmp (Argv[1], L"BOK") == 0))) {
(StriCmp (Argv[1], L"BOK") == 0)))
{
if (Argc == 3) {
EdbConfigBreak (DebuggerConfiguration, Argv[1], Argv[2]);
} else {
EdbConfigBreak (DebuggerConfiguration, Argv[1], NULL);
}
return EFI_SUCCESS;
}

View File

@ -8,13 +8,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Uefi.h>
#include "Edb.h"
EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate = {
EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate = {
EFI_DEBUGGER_SIGNATURE, // Signature
IsaEbc, // Isa
(EBC_DEBUGGER_MAJOR_VERSION << 16) |
EBC_DEBUGGER_MINOR_VERSION, // EfiDebuggerRevision
EBC_DEBUGGER_MINOR_VERSION, // EfiDebuggerRevision
(VM_MAJOR_VERSION << 16) |
VM_MINOR_VERSION, // EbcVmRevision
VM_MINOR_VERSION, // EbcVmRevision
{
EFI_DEBUGGER_CONFIGURATION_VERSION,
&mDebuggerPrivate,
@ -23,24 +23,30 @@ EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate = {
NULL, // Vol
NULL, // PciRootBridgeIo
mDebuggerCommandSet, // DebuggerCommandSet
{0}, // DebuggerSymbolContext
{ 0 }, // DebuggerSymbolContext
0, // DebuggerBreakpointCount
{{0}}, // DebuggerBreakpointContext
{
{ 0 }
}, // DebuggerBreakpointContext
0, // CallStackEntryCount
{{0}}, // CallStackEntry
{
{ 0 }
}, // CallStackEntry
0, // TraceEntryCount
{{0}}, // TraceEntry
{0}, // StepContext
{0}, // GoTilContext
0, // InstructionScope
EFI_DEBUG_DEFAULT_INSTRUCTION_NUMBER, // InstructionNumber
{
{ 0 }
}, // TraceEntry
{ 0 }, // StepContext
{ 0 }, // GoTilContext
0, // InstructionScope
EFI_DEBUG_DEFAULT_INSTRUCTION_NUMBER, // InstructionNumber
EFI_DEBUG_FLAG_EBC_BOE | EFI_DEBUG_FLAG_EBC_BOT, // FeatureFlags
0, // StatusFlags
FALSE, // EnablePageBreak
NULL // BreakEvent
};
CHAR16 *mExceptionStr[] = {
CHAR16 *mExceptionStr[] = {
L"EXCEPT_EBC_UNDEFINED",
L"EXCEPT_EBC_DIVIDE_ERROR",
L"EXCEPT_EBC_DEBUG",
@ -64,11 +70,11 @@ CHAR16 *mExceptionStr[] = {
**/
VOID
EdbClearAllBreakpoint (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN BOOLEAN NeedRemove
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN BOOLEAN NeedRemove
)
{
UINTN Index;
UINTN Index;
//
// Patch all the breakpoint
@ -78,7 +84,7 @@ EdbClearAllBreakpoint (
CopyMem (
(VOID *)(UINTN)DebuggerPrivate->DebuggerBreakpointContext[Index].BreakpointAddress,
&DebuggerPrivate->DebuggerBreakpointContext[Index].OldInstruction,
sizeof(UINT16)
sizeof (UINT16)
);
}
}
@ -88,13 +94,13 @@ EdbClearAllBreakpoint (
//
if (NeedRemove) {
DebuggerPrivate->DebuggerBreakpointCount = 0;
ZeroMem (DebuggerPrivate->DebuggerBreakpointContext, sizeof(DebuggerPrivate->DebuggerBreakpointContext));
ZeroMem (DebuggerPrivate->DebuggerBreakpointContext, sizeof (DebuggerPrivate->DebuggerBreakpointContext));
}
//
// Done
//
return ;
return;
}
/**
@ -106,11 +112,11 @@ EdbClearAllBreakpoint (
**/
VOID
EdbSetAllBreakpoint (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
)
{
UINTN Index;
UINT16 Data16;
UINTN Index;
UINT16 Data16;
//
// Set all the breakpoint (BREAK(3) : 0x0300)
@ -121,7 +127,7 @@ EdbSetAllBreakpoint (
CopyMem (
(VOID *)(UINTN)DebuggerPrivate->DebuggerBreakpointContext[Index].BreakpointAddress,
&Data16,
sizeof(UINT16)
sizeof (UINT16)
);
}
}
@ -134,7 +140,7 @@ EdbSetAllBreakpoint (
CopyMem (
(VOID *)(UINTN)DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX].BreakpointAddress,
&DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX].OldInstruction,
sizeof(UINT16)
sizeof (UINT16)
);
DebuggerPrivate->StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_BP;
}
@ -142,7 +148,7 @@ EdbSetAllBreakpoint (
//
// Done
//
return ;
return;
}
/**
@ -156,8 +162,8 @@ EdbSetAllBreakpoint (
**/
VOID
EdbCheckBreakpoint (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_SYSTEM_CONTEXT SystemContext
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
UINT64 Address;
@ -167,7 +173,7 @@ EdbCheckBreakpoint (
//
// Roll back IP for breakpoint instruction (BREAK(3) : 0x0300)
//
Address = SystemContext.SystemContextEbc->Ip - sizeof(UINT16);
Address = SystemContext.SystemContextEbc->Ip - sizeof (UINT16);
//
// Check if the breakpoint is hit
@ -175,7 +181,8 @@ EdbCheckBreakpoint (
IsHitBreakpoint = FALSE;
for (Index = 0; (Index < DebuggerPrivate->DebuggerBreakpointCount) && (Index < EFI_DEBUGGER_BREAKPOINT_MAX); Index++) {
if ((DebuggerPrivate->DebuggerBreakpointContext[Index].BreakpointAddress == Address) &&
(DebuggerPrivate->DebuggerBreakpointContext[Index].State)) {
(DebuggerPrivate->DebuggerBreakpointContext[Index].State))
{
IsHitBreakpoint = TRUE;
break;
}
@ -185,7 +192,7 @@ EdbCheckBreakpoint (
//
// If hit, record current breakpoint
//
DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX] = DebuggerPrivate->DebuggerBreakpointContext[Index];
DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX] = DebuggerPrivate->DebuggerBreakpointContext[Index];
DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX].State = TRUE;
//
// Update: IP and Instruction (NOTE: Since we not allow set breakpoint to BREAK 3, this update is safe)
@ -209,7 +216,8 @@ EdbCheckBreakpoint (
IsHitBreakpoint = FALSE;
for (Index = 0; (Index < DebuggerPrivate->DebuggerBreakpointCount) && (Index < EFI_DEBUGGER_BREAKPOINT_MAX); Index++) {
if ((DebuggerPrivate->DebuggerBreakpointContext[Index].BreakpointAddress == Address) &&
(DebuggerPrivate->DebuggerBreakpointContext[Index].State)) {
(DebuggerPrivate->DebuggerBreakpointContext[Index].State))
{
IsHitBreakpoint = TRUE;
break;
}
@ -234,7 +242,7 @@ EdbCheckBreakpoint (
//
ZeroMem (
&DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX],
sizeof(DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX])
sizeof (DebuggerPrivate->DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX])
);
}
}
@ -242,7 +250,7 @@ EdbCheckBreakpoint (
//
// Done
//
return ;
return;
}
/**
@ -253,13 +261,13 @@ EdbCheckBreakpoint (
**/
VOID
EdbClearSymbol (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
)
{
EFI_DEBUGGER_SYMBOL_CONTEXT *DebuggerSymbolContext;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
UINTN ObjectIndex;
UINTN Index;
EFI_DEBUGGER_SYMBOL_CONTEXT *DebuggerSymbolContext;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
UINTN ObjectIndex;
UINTN Index;
//
// Go throuth each object
@ -271,13 +279,14 @@ EdbClearSymbol (
// Go throuth each entry
//
for (Index = 0; Index < Object->EntryCount; Index++) {
ZeroMem (&Object->Entry[Index], sizeof(Object->Entry[Index]));
ZeroMem (&Object->Entry[Index], sizeof (Object->Entry[Index]));
}
ZeroMem (Object->Name, sizeof(Object->Name));
Object->EntryCount = 0;
Object->BaseAddress = 0;
ZeroMem (Object->Name, sizeof (Object->Name));
Object->EntryCount = 0;
Object->BaseAddress = 0;
Object->StartEntrypointRVA = 0;
Object->MainEntrypointRVA = 0;
Object->MainEntrypointRVA = 0;
//
// Free source buffer
//
@ -286,9 +295,10 @@ EdbClearSymbol (
Object->SourceBuffer[Index] = NULL;
}
}
DebuggerSymbolContext->ObjectCount = 0;
return ;
return;
}
/**
@ -303,17 +313,17 @@ EdbClearSymbol (
**/
EFI_STATUS
InitDebuggerPrivateData (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext,
IN BOOLEAN Initialized
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext,
IN BOOLEAN Initialized
)
{
//
// clear STEP flag in any condition.
//
if (SystemContext.SystemContextEbc->Flags & ((UINT64) VMFLAGS_STEP)) {
SystemContext.SystemContextEbc->Flags &= ~((UINT64) VMFLAGS_STEP);
if (SystemContext.SystemContextEbc->Flags & ((UINT64)VMFLAGS_STEP)) {
SystemContext.SystemContextEbc->Flags &= ~((UINT64)VMFLAGS_STEP);
}
if (!Initialized) {
@ -323,13 +333,13 @@ InitDebuggerPrivateData (
DebuggerPrivate->InstructionNumber = EFI_DEBUG_DEFAULT_INSTRUCTION_NUMBER;
DebuggerPrivate->DebuggerBreakpointCount = 0;
ZeroMem (DebuggerPrivate->DebuggerBreakpointContext, sizeof(DebuggerPrivate->DebuggerBreakpointContext));
ZeroMem (DebuggerPrivate->DebuggerBreakpointContext, sizeof (DebuggerPrivate->DebuggerBreakpointContext));
// DebuggerPrivate->StatusFlags = 0;
// DebuggerPrivate->StatusFlags = 0;
DebuggerPrivate->DebuggerSymbolContext.DisplaySymbol = TRUE;
DebuggerPrivate->DebuggerSymbolContext.DisplaySymbol = TRUE;
DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly = FALSE;
DebuggerPrivate->DebuggerSymbolContext.ObjectCount = 0;
DebuggerPrivate->DebuggerSymbolContext.ObjectCount = 0;
} else {
//
// Already initialized, just check Breakpoint here.
@ -367,21 +377,21 @@ InitDebuggerPrivateData (
**/
EFI_STATUS
DeinitDebuggerPrivateData (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext,
IN BOOLEAN Initialized
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext,
IN BOOLEAN Initialized
)
{
if (!Initialized) {
//
// If it does not want initialized state, de-init everything
//
DebuggerPrivate->FeatureFlags = EFI_DEBUG_FLAG_EBC_BOE | EFI_DEBUG_FLAG_EBC_BOT;
DebuggerPrivate->FeatureFlags = EFI_DEBUG_FLAG_EBC_BOE | EFI_DEBUG_FLAG_EBC_BOT;
DebuggerPrivate->CallStackEntryCount = 0;
DebuggerPrivate->TraceEntryCount = 0;
ZeroMem (DebuggerPrivate->CallStackEntry, sizeof(DebuggerPrivate->CallStackEntry));
ZeroMem (DebuggerPrivate->TraceEntry, sizeof(DebuggerPrivate->TraceEntry));
DebuggerPrivate->TraceEntryCount = 0;
ZeroMem (DebuggerPrivate->CallStackEntry, sizeof (DebuggerPrivate->CallStackEntry));
ZeroMem (DebuggerPrivate->TraceEntry, sizeof (DebuggerPrivate->TraceEntry));
//
// Clear all breakpoint
@ -402,7 +412,7 @@ DeinitDebuggerPrivateData (
//
// Clear Step context
//
ZeroMem (&mDebuggerPrivate.StepContext, sizeof(mDebuggerPrivate.StepContext));
ZeroMem (&mDebuggerPrivate.StepContext, sizeof (mDebuggerPrivate.StepContext));
DebuggerPrivate->StatusFlags = 0;
//
@ -423,10 +433,10 @@ DeinitDebuggerPrivateData (
**/
VOID
PrintExceptionReason (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext,
IN BOOLEAN Initialized
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN EFI_SYSTEM_CONTEXT SystemContext,
IN BOOLEAN Initialized
)
{
//
@ -461,7 +471,7 @@ PrintExceptionReason (
}
}
return ;
return;
}
/**
@ -477,15 +487,15 @@ PrintExceptionReason (
VOID
EFIAPI
EdbExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
CHAR16 InputBuffer[EFI_DEBUG_INPUS_BUFFER_SIZE];
CHAR16 *CommandArg;
EFI_DEBUGGER_COMMAND DebuggerCommand;
EFI_DEBUG_STATUS DebugStatus;
STATIC BOOLEAN mInitialized;
CHAR16 InputBuffer[EFI_DEBUG_INPUS_BUFFER_SIZE];
CHAR16 *CommandArg;
EFI_DEBUGGER_COMMAND DebuggerCommand;
EFI_DEBUG_STATUS DebugStatus;
STATIC BOOLEAN mInitialized;
mInitialized = FALSE;
@ -506,6 +516,7 @@ EdbExceptionHandler (
(UINTN)EBC_DEBUGGER_MINOR_VERSION
);
}
//
// Init Private Data
//
@ -526,6 +537,7 @@ EdbExceptionHandler (
EDBPrint (L"\nPlease enter command now, \'h\' for help.\n");
EDBPrint (L"(Using <Command> -b <...> to enable page break.)\n");
}
mInitialized = TRUE;
//
@ -552,7 +564,7 @@ EdbExceptionHandler (
//
if (CommandArg != NULL) {
if (StriCmp (CommandArg, L"-b") == 0) {
CommandArg = StrGetNextTokenLine (L" ");
CommandArg = StrGetNextTokenLine (L" ");
mDebuggerPrivate.EnablePageBreak = TRUE;
}
}
@ -560,7 +572,7 @@ EdbExceptionHandler (
//
// Dispatch command
//
DebugStatus = DebuggerCommand (CommandArg, &mDebuggerPrivate, ExceptionType, SystemContext);
DebugStatus = DebuggerCommand (CommandArg, &mDebuggerPrivate, ExceptionType, SystemContext);
mDebuggerPrivate.EnablePageBreak = FALSE;
//

View File

@ -11,8 +11,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "EdbCommon.h"
#define EBC_DEBUGGER_MAJOR_VERSION 1
#define EBC_DEBUGGER_MINOR_VERSION 0
#define EBC_DEBUGGER_MAJOR_VERSION 1
#define EBC_DEBUGGER_MINOR_VERSION 0
#define EFI_DEBUG_RETURN 1
#define EFI_DEBUG_BREAK 2
@ -27,8 +27,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
EfiDebuggerEntrypoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@ -44,11 +44,11 @@ EfiDebuggerEntrypoint (
VOID
EFIAPI
EdbExceptionHandler (
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
);
extern EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate;
extern EFI_DEBUGGER_PRIVATE_DATA mDebuggerPrivate;
#include "EdbSupport.h"
#include "EdbCommand.h"

View File

@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Edb.h"
CHAR16 *mBranchTypeStr[] = {
CHAR16 *mBranchTypeStr[] = {
L"(CALL)",
L"(CALLEX)",
L"(RET)",
@ -30,11 +30,11 @@ EdbBranchTypeToStr (
IN EFI_DEBUGGER_BRANCH_TYPE Type
)
{
if (Type < 0 || Type >= EfiDebuggerBranchTypeEbcMax) {
if ((Type < 0) || (Type >= EfiDebuggerBranchTypeEbcMax)) {
return L"(Unknown Type)";
}
return mBranchTypeStr [Type];
return mBranchTypeStr[Type];
}
/**
@ -51,20 +51,20 @@ EdbBranchTypeToStr (
**/
EFI_DEBUG_STATUS
DebuggerCallStack (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
INTN Index;
UINTN SubIndex;
CHAR8 *FuncName;
EFI_DEBUGGER_CALLSTACK_CONTEXT *CallStackEntry;
BOOLEAN ShowParameter;
UINTN ParameterNumber;
INTN Index;
UINTN SubIndex;
CHAR8 *FuncName;
EFI_DEBUGGER_CALLSTACK_CONTEXT *CallStackEntry;
BOOLEAN ShowParameter;
UINTN ParameterNumber;
ShowParameter = FALSE;
ShowParameter = FALSE;
ParameterNumber = EFI_DEBUGGER_CALL_DEFAULT_PARAMETER;
//
@ -76,7 +76,7 @@ DebuggerCallStack (
// Clear Call-Stack
//
DebuggerPrivate->CallStackEntryCount = 0;
ZeroMem (DebuggerPrivate->CallStackEntry, sizeof(DebuggerPrivate->CallStackEntry));
ZeroMem (DebuggerPrivate->CallStackEntry, sizeof (DebuggerPrivate->CallStackEntry));
EDBPrint (L"Call-Stack is cleared\n");
return EFI_DEBUG_CONTINUE;
} else if (StriCmp (CommandArg, L"p") == 0) {
@ -84,7 +84,7 @@ DebuggerCallStack (
// Print Call-Stack with parameter
//
ShowParameter = TRUE;
CommandArg = StrGetNextTokenLine (L" ");
CommandArg = StrGetNextTokenLine (L" ");
if (CommandArg != NULL) {
//
// Try to get the parameter number
@ -119,7 +119,7 @@ DebuggerCallStack (
EDBPrint (L"Call-Stack (TOP):\n");
EDBPrint (L" Caller Callee Name\n");
EDBPrint (L" ================== ================== ========\n");
//EDBPrint (L" 0x00000000FFFFFFFF 0xFFFFFFFF00000000 EfiMain\n");
// EDBPrint (L" 0x00000000FFFFFFFF 0xFFFFFFFF00000000 EfiMain\n");
for (Index = (INTN)(DebuggerPrivate->CallStackEntryCount - 1); Index >= 0; Index--) {
//
// Get CallStack and print
@ -134,13 +134,14 @@ DebuggerCallStack (
if (FuncName != NULL) {
EDBPrint (L" %a()", FuncName);
}
EDBPrint (L"\n");
if (ShowParameter) {
//
// Print parameter
//
if (sizeof(UINTN) == sizeof(UINT64)) {
if (sizeof (UINTN) == sizeof (UINT64)) {
EDBPrint (
L" Parameter Address (0x%016lx) (\n",
CallStackEntry->ParameterAddr
@ -149,6 +150,7 @@ DebuggerCallStack (
EDBPrint (L" )\n");
continue;
}
//
// Print each parameter
//
@ -156,6 +158,7 @@ DebuggerCallStack (
if (SubIndex % 2 == 0) {
EDBPrint (L" ");
}
EDBPrint (
L"0x%016lx, ",
CallStackEntry->Parameter[SubIndex]
@ -164,9 +167,11 @@ DebuggerCallStack (
EDBPrint (L"\n");
}
}
if (SubIndex % 2 == 0) {
EDBPrint (L" ");
}
EDBPrint (
L"0x%016lx\n",
CallStackEntry->Parameter[SubIndex]
@ -176,7 +181,8 @@ DebuggerCallStack (
// break only for parameter
//
if ((((DebuggerPrivate->CallStackEntryCount - Index) % (16 / ParameterNumber)) == 0) &&
(Index != 0)) {
(Index != 0))
{
if (SetPageBreak ()) {
break;
}
@ -190,6 +196,7 @@ DebuggerCallStack (
EDBPrint (L" )\n");
continue;
}
//
// Print each parameter
//
@ -197,6 +204,7 @@ DebuggerCallStack (
if (SubIndex % 4 == 0) {
EDBPrint (L" ");
}
EDBPrint (
L"0x%08x, ",
CallStackEntry->Parameter[SubIndex]
@ -205,9 +213,11 @@ DebuggerCallStack (
EDBPrint (L"\n");
}
}
if (SubIndex % 4 == 0) {
EDBPrint (L" ");
}
EDBPrint (
L"0x%08x\n",
CallStackEntry->Parameter[SubIndex]
@ -217,7 +227,8 @@ DebuggerCallStack (
// break only for parameter
//
if ((((DebuggerPrivate->CallStackEntryCount - Index) % (32 / ParameterNumber)) == 0) &&
(Index != 0)) {
(Index != 0))
{
if (SetPageBreak ()) {
break;
}
@ -246,10 +257,10 @@ DebuggerCallStack (
**/
EFI_DEBUG_STATUS
DebuggerInstructionBranch (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Index;
@ -263,11 +274,12 @@ DebuggerInstructionBranch (
// Clear Trace
//
DebuggerPrivate->TraceEntryCount = 0;
ZeroMem (DebuggerPrivate->TraceEntry, sizeof(DebuggerPrivate->TraceEntry));
ZeroMem (DebuggerPrivate->TraceEntry, sizeof (DebuggerPrivate->TraceEntry));
EDBPrint (L"Instruction Trace is cleared\n");
} else {
EDBPrint (L"Trace argument Invalid\n");
}
return EFI_DEBUG_CONTINUE;
}
@ -289,7 +301,7 @@ DebuggerInstructionBranch (
EDBPrint (L"Instruction Trace (->Latest):\n");
EDBPrint (L" Source Addr Destination Addr Type\n");
EDBPrint (L" ================== ================== ========\n");
//EDBPrint (L" 0x00000000FFFFFFFF 0xFFFFFFFF00000000 (CALLEX)\n");
// EDBPrint (L" 0x00000000FFFFFFFF 0xFFFFFFFF00000000 (CALLEX)\n");
for (Index = 0; Index < DebuggerPrivate->TraceEntryCount; Index++) {
EDBPrint (
L" 0x%016lx 0x%016lx %s\n",

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Edb.h"
/**
DebuggerCommand - BreakOnCALL.
@ -23,10 +22,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerBreakOnCALL (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//
@ -69,10 +68,10 @@ DebuggerBreakOnCALL (
**/
EFI_DEBUG_STATUS
DebuggerBreakOnCALLEX (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//
@ -115,10 +114,10 @@ DebuggerBreakOnCALLEX (
**/
EFI_DEBUG_STATUS
DebuggerBreakOnRET (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//
@ -161,10 +160,10 @@ DebuggerBreakOnRET (
**/
EFI_DEBUG_STATUS
DebuggerBreakOnEntrypoint (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//
@ -209,10 +208,10 @@ DebuggerBreakOnEntrypoint (
**/
EFI_DEBUG_STATUS
DebuggerBreakOnThunk (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//
@ -256,10 +255,10 @@ DebuggerBreakOnThunk (
**/
EFI_DEBUG_STATUS
DebuggerBreakOnKey (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//

View File

@ -20,10 +20,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
BOOLEAN
IsEBCBREAK3 (
IN UINTN Address
IN UINTN Address
)
{
if (GET_OPCODE(Address) != OPCODE_BREAK) {
if (GET_OPCODE (Address) != OPCODE_BREAK) {
return FALSE;
}
@ -47,8 +47,8 @@ IsEBCBREAK3 (
**/
BOOLEAN
DebuggerBreakpointIsDuplicated (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Address
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Address
)
{
UINTN Index;
@ -85,8 +85,8 @@ DebuggerBreakpointIsDuplicated (
**/
EFI_STATUS
DebuggerBreakpointAdd (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Address
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Address
)
{
//
@ -114,15 +114,15 @@ DebuggerBreakpointAdd (
// Set the breakpoint
//
DebuggerPrivate->DebuggerBreakpointContext[DebuggerPrivate->DebuggerBreakpointCount].BreakpointAddress = Address;
DebuggerPrivate->DebuggerBreakpointContext[DebuggerPrivate->DebuggerBreakpointCount].State = TRUE;
DebuggerPrivate->DebuggerBreakpointContext[DebuggerPrivate->DebuggerBreakpointCount].OldInstruction = 0;
DebuggerPrivate->DebuggerBreakpointContext[DebuggerPrivate->DebuggerBreakpointCount].State = TRUE;
DebuggerPrivate->DebuggerBreakpointContext[DebuggerPrivate->DebuggerBreakpointCount].OldInstruction = 0;
CopyMem (
&DebuggerPrivate->DebuggerBreakpointContext[DebuggerPrivate->DebuggerBreakpointCount].OldInstruction,
(VOID *)Address,
sizeof(UINT16)
sizeof (UINT16)
);
DebuggerPrivate->DebuggerBreakpointCount ++;
DebuggerPrivate->DebuggerBreakpointCount++;
//
// Done
@ -143,14 +143,15 @@ DebuggerBreakpointAdd (
**/
EFI_STATUS
DebuggerBreakpointDel (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Index
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Index
)
{
UINTN BpIndex;
UINTN BpIndex;
if ((Index >= EFI_DEBUGGER_BREAKPOINT_MAX) ||
(Index >= DebuggerPrivate->DebuggerBreakpointCount)) {
(Index >= DebuggerPrivate->DebuggerBreakpointCount))
{
return EFI_NOT_FOUND;
}
@ -164,12 +165,13 @@ DebuggerBreakpointDel (
sizeof (DebuggerPrivate->DebuggerBreakpointContext[BpIndex])
);
}
ZeroMem (
&DebuggerPrivate->DebuggerBreakpointContext[BpIndex],
sizeof(DebuggerPrivate->DebuggerBreakpointContext[BpIndex])
sizeof (DebuggerPrivate->DebuggerBreakpointContext[BpIndex])
);
DebuggerPrivate->DebuggerBreakpointCount --;
DebuggerPrivate->DebuggerBreakpointCount--;
//
// Done
@ -190,12 +192,13 @@ DebuggerBreakpointDel (
**/
EFI_STATUS
DebuggerBreakpointDis (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Index
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Index
)
{
if ((Index >= EFI_DEBUGGER_BREAKPOINT_MAX) ||
(Index >= DebuggerPrivate->DebuggerBreakpointCount)) {
(Index >= DebuggerPrivate->DebuggerBreakpointCount))
{
return EFI_NOT_FOUND;
}
@ -220,12 +223,13 @@ DebuggerBreakpointDis (
**/
EFI_STATUS
DebuggerBreakpointEn (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Index
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN UINTN Index
)
{
if ((Index >= EFI_DEBUGGER_BREAKPOINT_MAX) ||
(Index >= DebuggerPrivate->DebuggerBreakpointCount)) {
(Index >= DebuggerPrivate->DebuggerBreakpointCount))
{
return EFI_NOT_FOUND;
}
@ -251,13 +255,13 @@ DebuggerBreakpointEn (
**/
EFI_DEBUG_STATUS
DebuggerBreakpointList (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Index;
UINTN Index;
//
// Check breakpoint cound
@ -277,8 +281,8 @@ DebuggerBreakpointList (
EDBPrint (L"Breakpoint :\n");
EDBPrint (L" Index Address Status\n");
EDBPrint (L"======= ================== ========\n");
//EDBPrint (L" 1 0xFFFFFFFF00000000 *\n");
//EDBPrint (L" 12 0x00000000FFFFFFFF\n");
// EDBPrint (L" 1 0xFFFFFFFF00000000 *\n");
// EDBPrint (L" 12 0x00000000FFFFFFFF\n");
for (Index = 0; Index < DebuggerPrivate->DebuggerBreakpointCount; Index++) {
//
// Print the breakpoint
@ -311,14 +315,14 @@ DebuggerBreakpointList (
**/
EFI_DEBUG_STATUS
DebuggerBreakpointSet (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Address;
EFI_STATUS Status;
UINTN Address;
EFI_STATUS Status;
if (CommandArg == NULL) {
EDBPrint (L"BreakpointSet Argument error!\n");
@ -331,7 +335,7 @@ DebuggerBreakpointSet (
Status = Symboltoi (CommandArg, &Address);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
Address = Xtoi(CommandArg);
Address = Xtoi (CommandArg);
} else {
//
// Something wrong, let Symboltoi print error info.
@ -345,7 +349,7 @@ DebuggerBreakpointSet (
// Add breakpoint
//
Status = DebuggerBreakpointAdd (DebuggerPrivate, Address);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"BreakpointSet error!\n");
}
@ -369,14 +373,14 @@ DebuggerBreakpointSet (
**/
EFI_DEBUG_STATUS
DebuggerBreakpointClear (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Index;
EFI_STATUS Status;
UINTN Index;
EFI_STATUS Status;
if (CommandArg == NULL) {
EDBPrint (L"BreakpointClear Argument error!\n");
@ -388,7 +392,7 @@ DebuggerBreakpointClear (
// delete all breakpoint
//
DebuggerPrivate->DebuggerBreakpointCount = 0;
ZeroMem (DebuggerPrivate->DebuggerBreakpointContext, sizeof(DebuggerPrivate->DebuggerBreakpointContext));
ZeroMem (DebuggerPrivate->DebuggerBreakpointContext, sizeof (DebuggerPrivate->DebuggerBreakpointContext));
EDBPrint (L"All the Breakpoint is cleared\n");
return EFI_DEBUG_CONTINUE;
}
@ -396,14 +400,15 @@ DebuggerBreakpointClear (
//
// Get breakpoint index
//
Index = Atoi(CommandArg);
if (Index == (UINTN) -1) {
Index = Atoi (CommandArg);
if (Index == (UINTN)-1) {
EDBPrint (L"BreakpointClear Argument error!\n");
return EFI_DEBUG_CONTINUE;
}
if ((Index >= EFI_DEBUGGER_BREAKPOINT_MAX) ||
(Index >= DebuggerPrivate->DebuggerBreakpointCount)) {
(Index >= DebuggerPrivate->DebuggerBreakpointCount))
{
EDBPrint (L"BreakpointClear error!\n");
return EFI_DEBUG_CONTINUE;
}
@ -412,7 +417,7 @@ DebuggerBreakpointClear (
// Delete breakpoint
//
Status = DebuggerBreakpointDel (DebuggerPrivate, Index);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"BreakpointClear error!\n");
}
@ -436,14 +441,14 @@ DebuggerBreakpointClear (
**/
EFI_DEBUG_STATUS
DebuggerBreakpointDisable (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Index;
EFI_STATUS Status;
UINTN Index;
EFI_STATUS Status;
if (CommandArg == NULL) {
EDBPrint (L"BreakpointDisable Argument error!\n");
@ -457,6 +462,7 @@ DebuggerBreakpointDisable (
for (Index = 0; Index < DebuggerPrivate->DebuggerBreakpointCount; Index++) {
Status = DebuggerBreakpointDis (DebuggerPrivate, Index);
}
EDBPrint (L"All the Breakpoint is disabled\n");
return EFI_DEBUG_CONTINUE;
}
@ -464,8 +470,8 @@ DebuggerBreakpointDisable (
//
// Get breakpoint index
//
Index = Atoi(CommandArg);
if (Index == (UINTN) -1) {
Index = Atoi (CommandArg);
if (Index == (UINTN)-1) {
EDBPrint (L"BreakpointDisable Argument error!\n");
return EFI_DEBUG_CONTINUE;
}
@ -474,7 +480,7 @@ DebuggerBreakpointDisable (
// Disable breakpoint
//
Status = DebuggerBreakpointDis (DebuggerPrivate, Index);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"BreakpointDisable error!\n");
}
@ -497,14 +503,14 @@ DebuggerBreakpointDisable (
**/
EFI_DEBUG_STATUS
DebuggerBreakpointEnable (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Index;
EFI_STATUS Status;
UINTN Index;
EFI_STATUS Status;
if (CommandArg == NULL) {
EDBPrint (L"BreakpointEnable Argument error!\n");
@ -518,6 +524,7 @@ DebuggerBreakpointEnable (
for (Index = 0; Index < DebuggerPrivate->DebuggerBreakpointCount; Index++) {
Status = DebuggerBreakpointEn (DebuggerPrivate, Index);
}
EDBPrint (L"All the Breakpoint is enabled\n");
return EFI_DEBUG_CONTINUE;
}
@ -525,8 +532,8 @@ DebuggerBreakpointEnable (
//
// Get breakpoint index
//
Index = Atoi(CommandArg);
if (Index == (UINTN) -1) {
Index = Atoi (CommandArg);
if (Index == (UINTN)-1) {
EDBPrint (L"BreakpointEnable Argument error!\n");
return EFI_DEBUG_CONTINUE;
}
@ -535,7 +542,7 @@ DebuggerBreakpointEnable (
// Enable breakpoint
//
Status = DebuggerBreakpointEn (DebuggerPrivate, Index);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"BreakpointEnable error!\n");
}

View File

@ -22,10 +22,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerExtIoIB (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -35,7 +35,6 @@ DebuggerExtIoIB (
return EFI_DEBUG_CONTINUE;
}
/**
DebuggerCommand - IW.
@ -51,10 +50,10 @@ DebuggerExtIoIB (
**/
EFI_DEBUG_STATUS
DebuggerExtIoIW (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -79,10 +78,10 @@ DebuggerExtIoIW (
**/
EFI_DEBUG_STATUS
DebuggerExtIoID (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -106,10 +105,10 @@ DebuggerExtIoID (
**/
EFI_DEBUG_STATUS
DebuggerExtIoOB (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -119,7 +118,6 @@ DebuggerExtIoOB (
return EFI_DEBUG_CONTINUE;
}
/**
DebuggerCommand - OW.
@ -134,10 +132,10 @@ DebuggerExtIoOB (
**/
EFI_DEBUG_STATUS
DebuggerExtIoOW (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -147,7 +145,6 @@ DebuggerExtIoOW (
return EFI_DEBUG_CONTINUE;
}
/**
DebuggerCommand - OD.
@ -162,10 +159,10 @@ DebuggerExtIoOW (
**/
EFI_DEBUG_STATUS
DebuggerExtIoOD (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");

View File

@ -22,10 +22,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerExtPciPCIL (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -49,10 +49,10 @@ DebuggerExtPciPCIL (
**/
EFI_DEBUG_STATUS
DebuggerExtPciPCID (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -76,10 +76,10 @@ DebuggerExtPciPCID (
**/
EFI_DEBUG_STATUS
DebuggerExtPciCFGB (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -89,7 +89,6 @@ DebuggerExtPciCFGB (
return EFI_DEBUG_CONTINUE;
}
/**
DebuggerCommand - CFGW.
@ -104,10 +103,10 @@ DebuggerExtPciCFGB (
**/
EFI_DEBUG_STATUS
DebuggerExtPciCFGW (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");
@ -131,10 +130,10 @@ DebuggerExtPciCFGW (
**/
EFI_DEBUG_STATUS
DebuggerExtPciCFGD (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EDBPrint (L"Unsupported\n");

View File

@ -24,15 +24,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerGo (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Address;
CHAR16 *CommandStr;
EFI_STATUS Status;
UINTN Address;
CHAR16 *CommandStr;
EFI_STATUS Status;
//
// Check argument
@ -48,7 +48,7 @@ DebuggerGo (
Status = Symboltoi (CommandStr, &Address);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
Address = Xtoi(CommandStr);
Address = Xtoi (CommandStr);
} else {
//
// Something wrong, let Symboltoi print error info.
@ -57,8 +57,9 @@ DebuggerGo (
return EFI_DEBUG_CONTINUE;
}
}
DebuggerPrivate->GoTilContext.BreakAddress = Address;
DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_GT;
DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_GT;
} else {
EDBPrint (L"Command Argument error!\n");
return EFI_DEBUG_CONTINUE;

View File

@ -22,13 +22,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerHelp (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN Index;
UINTN Index;
//
// if no argument, print all the command title
@ -41,6 +41,7 @@ DebuggerHelp (
EDBPrint (DebuggerPrivate->DebuggerCommandSet[Index].CommandTitle);
}
}
return EFI_DEBUG_CONTINUE;
}

View File

@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Edb.h"
/**
Display memory unit.
@ -25,34 +24,34 @@ EdbDisplayMemoryUnit (
IN EDB_DATA_WIDTH Width
)
{
UINT8 Data8;
UINT16 Data16;
UINT32 Data32;
UINT64 Data64;
UINT8 Data8;
UINT16 Data16;
UINT32 Data32;
UINT64 Data64;
//
// Print according to width
//
switch (Width) {
case EdbWidthUint8:
CopyMem (&Data8, (VOID *)Address, sizeof(UINT8));
EDBPrint (L"%02x ", Data8);
return sizeof(UINT8);
case EdbWidthUint16:
CopyMem (&Data16, (VOID *)Address, sizeof(UINT16));
EDBPrint (L"%04x ", Data16);
return sizeof(UINT16);
case EdbWidthUint32:
CopyMem (&Data32, (VOID *)Address, sizeof(UINT32));
EDBPrint (L"%08x ", Data32);
return sizeof(UINT32);
case EdbWidthUint64:
CopyMem (&Data64, (VOID *)Address, sizeof(UINT64));
EDBPrint (L"%016lx ", Data64);
return sizeof(UINT64);
default:
ASSERT (FALSE);
break;
case EdbWidthUint8:
CopyMem (&Data8, (VOID *)Address, sizeof (UINT8));
EDBPrint (L"%02x ", Data8);
return sizeof (UINT8);
case EdbWidthUint16:
CopyMem (&Data16, (VOID *)Address, sizeof (UINT16));
EDBPrint (L"%04x ", Data16);
return sizeof (UINT16);
case EdbWidthUint32:
CopyMem (&Data32, (VOID *)Address, sizeof (UINT32));
EDBPrint (L"%08x ", Data32);
return sizeof (UINT32);
case EdbWidthUint64:
CopyMem (&Data64, (VOID *)Address, sizeof (UINT64));
EDBPrint (L"%016lx ", Data64);
return sizeof (UINT64);
default:
ASSERT (FALSE);
break;
}
//
@ -72,9 +71,9 @@ EdbDisplayMemoryUnit (
**/
VOID
EdbDisplayMemory (
IN UINTN Address,
IN UINTN Count,
IN EDB_DATA_WIDTH Width
IN UINTN Address,
IN UINTN Count,
IN EDB_DATA_WIDTH Width
)
{
UINTN LineNumber;
@ -84,27 +83,27 @@ EdbDisplayMemory (
UINTN NumberInLine;
if (Count == 0) {
return ;
return;
}
//
// Get line number and byte number
//
switch (Width) {
case EdbWidthUint8:
NumberInLine = 16;
break;
case EdbWidthUint16:
NumberInLine = 8;
break;
case EdbWidthUint32:
NumberInLine = 4;
break;
case EdbWidthUint64:
NumberInLine = 2;
break;
default:
return;
case EdbWidthUint8:
NumberInLine = 16;
break;
case EdbWidthUint16:
NumberInLine = 8;
break;
case EdbWidthUint32:
NumberInLine = 4;
break;
case EdbWidthUint64:
NumberInLine = 2;
break;
default:
return;
}
LineNumber = Count / NumberInLine;
@ -118,12 +117,12 @@ EdbDisplayMemory (
// Print each line
//
for (LineIndex = 0; LineIndex < LineNumber; LineIndex++) {
//
// Break check
//
if (((LineIndex % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
(LineIndex != 0)) {
(LineIndex != 0))
{
if (SetPageBreak ()) {
break;
}
@ -133,6 +132,7 @@ EdbDisplayMemory (
for (ByteIndex = 0; ByteIndex < NumberInLine; ByteIndex++) {
Address += EdbDisplayMemoryUnit (Address, Width);
}
EDBPrint (L"\n");
}
@ -140,7 +140,8 @@ EdbDisplayMemory (
// Break check
//
if (((LineIndex % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
(LineIndex != 0)) {
(LineIndex != 0))
{
if (SetPageBreak ()) {
return;
}
@ -154,7 +155,7 @@ EdbDisplayMemory (
Address += EdbDisplayMemoryUnit (Address, Width);
}
return ;
return;
}
/**
@ -168,29 +169,29 @@ EdbDisplayMemory (
**/
VOID
EdbEnterMemory (
IN UINTN Address,
IN VOID *Value,
IN EDB_DATA_WIDTH Width
IN UINTN Address,
IN VOID *Value,
IN EDB_DATA_WIDTH Width
)
{
switch (Width) {
case EdbWidthUint8:
CopyMem ((VOID *)Address, Value, sizeof(UINT8));
break;
case EdbWidthUint16:
CopyMem ((VOID *)Address, Value, sizeof(UINT16));
break;
case EdbWidthUint32:
CopyMem ((VOID *)Address, Value, sizeof(UINT32));
break;
case EdbWidthUint64:
CopyMem ((VOID *)Address, Value, sizeof(UINT64));
break;
default:
break;
case EdbWidthUint8:
CopyMem ((VOID *)Address, Value, sizeof (UINT8));
break;
case EdbWidthUint16:
CopyMem ((VOID *)Address, Value, sizeof (UINT16));
break;
case EdbWidthUint32:
CopyMem ((VOID *)Address, Value, sizeof (UINT32));
break;
case EdbWidthUint64:
CopyMem ((VOID *)Address, Value, sizeof (UINT64));
break;
default:
break;
}
return ;
return;
}
/**
@ -207,14 +208,14 @@ EdbEnterMemory (
**/
EFI_STATUS
EdbGetMemoryAddressCount (
IN CHAR16 *CommandArg,
IN UINTN *Address,
IN UINTN *Count
IN CHAR16 *CommandArg,
IN UINTN *Address,
IN UINTN *Count
)
{
CHAR16 *CommandStr;
UINTN MemAddress;
EFI_STATUS Status;
CHAR16 *CommandStr;
UINTN MemAddress;
EFI_STATUS Status;
//
// Get Address
@ -224,10 +225,11 @@ EdbGetMemoryAddressCount (
EDBPrint (L"Memory: Address error!\n");
return EFI_INVALID_PARAMETER;
}
Status = Symboltoi (CommandStr, &MemAddress);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
MemAddress = Xtoi(CommandStr);
MemAddress = Xtoi (CommandStr);
} else {
//
// Something wrong, let Symboltoi print error info.
@ -236,6 +238,7 @@ EdbGetMemoryAddressCount (
return EFI_INVALID_PARAMETER;
}
}
*Address = MemAddress;
//
@ -245,7 +248,7 @@ EdbGetMemoryAddressCount (
if (CommandStr == NULL) {
*Count = 1;
} else {
*Count = Xtoi(CommandStr);
*Count = Xtoi (CommandStr);
}
//
@ -268,14 +271,14 @@ EdbGetMemoryAddressCount (
**/
EFI_STATUS
EdbGetMemoryAddressValue (
IN CHAR16 *CommandArg,
IN UINTN *Address,
IN UINT64 *Value
IN CHAR16 *CommandArg,
IN UINTN *Address,
IN UINT64 *Value
)
{
CHAR16 *CommandStr;
UINTN MemAddress;
EFI_STATUS Status;
CHAR16 *CommandStr;
UINTN MemAddress;
EFI_STATUS Status;
//
// Get Address
@ -285,10 +288,11 @@ EdbGetMemoryAddressValue (
EDBPrint (L"Memory: Address error!\n");
return EFI_INVALID_PARAMETER;
}
Status = Symboltoi (CommandStr, &MemAddress);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
MemAddress = Xtoi(CommandStr);
MemAddress = Xtoi (CommandStr);
} else {
//
// Something wrong, let Symboltoi print error info.
@ -297,6 +301,7 @@ EdbGetMemoryAddressValue (
return EFI_INVALID_PARAMETER;
}
}
*Address = MemAddress;
//
@ -307,7 +312,8 @@ EdbGetMemoryAddressValue (
EDBPrint (L"Memory: Value error!\n");
return EFI_INVALID_PARAMETER;
}
*Value = LXtoi(CommandStr);
*Value = LXtoi (CommandStr);
//
// Done
@ -327,19 +333,19 @@ EdbGetMemoryAddressValue (
**/
EFI_DEBUG_STATUS
DebuggerMemoryDisplay (
IN CHAR16 *CommandArg,
IN EDB_DATA_WIDTH Width
IN CHAR16 *CommandArg,
IN EDB_DATA_WIDTH Width
)
{
EFI_STATUS Status;
UINTN Address;
UINTN Count;
EFI_STATUS Status;
UINTN Address;
UINTN Count;
//
// Get memory address and count
//
Status = EdbGetMemoryAddressCount (CommandArg, &Address, &Count);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_DEBUG_CONTINUE;
}
@ -366,19 +372,19 @@ DebuggerMemoryDisplay (
**/
EFI_DEBUG_STATUS
DebuggerMemoryEnter (
IN CHAR16 *CommandArg,
IN EDB_DATA_WIDTH Width
IN CHAR16 *CommandArg,
IN EDB_DATA_WIDTH Width
)
{
EFI_STATUS Status;
UINTN Address;
UINT64 Value;
EFI_STATUS Status;
UINTN Address;
UINT64 Value;
//
// Get memory address and value
//
Status = EdbGetMemoryAddressValue (CommandArg, &Address, &Value);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_DEBUG_CONTINUE;
}
@ -407,10 +413,10 @@ DebuggerMemoryEnter (
**/
EFI_DEBUG_STATUS
DebuggerMemoryDB (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryDisplay (CommandArg, EdbWidthUint8);
@ -430,10 +436,10 @@ DebuggerMemoryDB (
**/
EFI_DEBUG_STATUS
DebuggerMemoryDW (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryDisplay (CommandArg, EdbWidthUint16);
@ -453,10 +459,10 @@ DebuggerMemoryDW (
**/
EFI_DEBUG_STATUS
DebuggerMemoryDD (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryDisplay (CommandArg, EdbWidthUint32);
@ -476,10 +482,10 @@ DebuggerMemoryDD (
**/
EFI_DEBUG_STATUS
DebuggerMemoryDQ (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryDisplay (CommandArg, EdbWidthUint64);
@ -499,10 +505,10 @@ DebuggerMemoryDQ (
**/
EFI_DEBUG_STATUS
DebuggerMemoryEB (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryEnter (CommandArg, EdbWidthUint8);
@ -522,10 +528,10 @@ DebuggerMemoryEB (
**/
EFI_DEBUG_STATUS
DebuggerMemoryEW (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryEnter (CommandArg, EdbWidthUint16);
@ -545,10 +551,10 @@ DebuggerMemoryEW (
**/
EFI_DEBUG_STATUS
DebuggerMemoryED (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryEnter (CommandArg, EdbWidthUint32);
@ -568,10 +574,10 @@ DebuggerMemoryED (
**/
EFI_DEBUG_STATUS
DebuggerMemoryEQ (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return DebuggerMemoryEnter (CommandArg, EdbWidthUint64);

View File

@ -28,10 +28,10 @@ Abstract:
**/
EFI_DEBUG_STATUS
DebuggerQuit (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return EFI_DEBUG_RETURN;

View File

@ -22,10 +22,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerRegister (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
CHAR16 *RegName;
@ -80,6 +80,7 @@ DebuggerRegister (
EDBPrint (L"Invalid Register Value\n");
return EFI_DEBUG_CONTINUE;
}
RegVal = LXtoi (RegValStr);
//

View File

@ -22,14 +22,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_DEBUG_STATUS
DebuggerScope (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EFI_STATUS Status;
UINTN Address;
EFI_STATUS Status;
UINTN Address;
if (CommandArg == NULL) {
EDBPrint (L"Scope: invalid Address\n");
@ -42,7 +42,7 @@ DebuggerScope (
Status = Symboltoi (CommandArg, &Address);
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
Address = Xtoi(CommandArg);
Address = Xtoi (CommandArg);
} else {
//
// Something wrong, let Symboltoi print error info.
@ -51,6 +51,7 @@ DebuggerScope (
return EFI_DEBUG_CONTINUE;
}
}
DebuggerPrivate->InstructionScope = Address;
EDBPrint (L"Scope: 0x%x\n", DebuggerPrivate->InstructionScope);
EdbShowDisasm (DebuggerPrivate, SystemContext);
@ -75,10 +76,10 @@ DebuggerScope (
**/
EFI_DEBUG_STATUS
DebuggerList (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
if (CommandArg == NULL) {
@ -87,7 +88,7 @@ DebuggerList (
//
// Load new list number
//
DebuggerPrivate->InstructionNumber = Atoi(CommandArg);
DebuggerPrivate->InstructionNumber = Atoi (CommandArg);
EDBPrint (L"List Number: %d\n", DebuggerPrivate->InstructionNumber);
EdbShowDisasm (DebuggerPrivate, SystemContext);
}

View File

@ -20,10 +20,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
BOOLEAN
IsEBCCALL (
IN UINTN Address
IN UINTN Address
)
{
if (GET_OPCODE(Address) != OPCODE_CALL) {
if (GET_OPCODE (Address) != OPCODE_CALL) {
return FALSE;
}
@ -46,10 +46,10 @@ IsEBCCALL (
**/
BOOLEAN
IsEBCRET (
IN UINTN Address
IN UINTN Address
)
{
if (GET_OPCODE(Address) != OPCODE_RET) {
if (GET_OPCODE (Address) != OPCODE_RET) {
return FALSE;
}
@ -74,10 +74,10 @@ IsEBCRET (
**/
EFI_DEBUG_STATUS
DebuggerStepInto (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
SystemContext.SystemContextEbc->Flags |= VMFLAGS_STEP;
@ -99,13 +99,13 @@ DebuggerStepInto (
**/
EFI_DEBUG_STATUS
DebuggerStepOver (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
if (IsEBCCALL((UINTN)SystemContext.SystemContextEbc->Ip)) {
if (IsEBCCALL ((UINTN)SystemContext.SystemContextEbc->Ip)) {
//
// Check CALL (NOTE: CALLEX is exclusive)
//
@ -134,13 +134,13 @@ DebuggerStepOver (
**/
EFI_DEBUG_STATUS
DebuggerStepOut (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
if (IsEBCRET((UINTN)SystemContext.SystemContextEbc->Ip)) {
if (IsEBCRET ((UINTN)SystemContext.SystemContextEbc->Ip)) {
//
// Check RET
//

View File

@ -19,17 +19,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
CHAR16 *
GetFileNameFromFullPath (
IN CHAR16 *FullPath
IN CHAR16 *FullPath
)
{
CHAR16 *FileName;
CHAR16 *TempFileName;
CHAR16 *FileName;
CHAR16 *TempFileName;
FileName = FullPath;
FileName = FullPath;
TempFileName = StrGetNewTokenLine (FullPath, L"\\");
while (TempFileName != NULL) {
FileName = TempFileName;
FileName = TempFileName;
TempFileName = StrGetNextTokenLine (L"\\");
PatchForStrTokenBefore (TempFileName, L'\\');
}
@ -48,10 +48,10 @@ GetFileNameFromFullPath (
**/
CHAR16 *
GetDirNameFromFullPath (
IN CHAR16 *FullPath
IN CHAR16 *FullPath
)
{
CHAR16 *FileName;
CHAR16 *FileName;
FileName = GetFileNameFromFullPath (FullPath);
if (FileName != FullPath) {
@ -75,14 +75,14 @@ GetDirNameFromFullPath (
**/
CHAR16 *
ConstructFullPath (
IN CHAR16 *DirPath,
IN CHAR16 *FilePath,
IN UINTN Size
IN CHAR16 *DirPath,
IN CHAR16 *FilePath,
IN UINTN Size
)
{
UINTN DirPathSize;
UINTN DirPathSize;
DirPathSize = StrLen(DirPath);
DirPathSize = StrLen (DirPath);
*(DirPath + DirPathSize) = L'\\';
StrnCatS (DirPath, DirPathSize + Size + 1, FilePath, Size);
@ -91,7 +91,7 @@ ConstructFullPath (
return DirPath;
}
CHAR16 *mSymbolTypeStr[] = {
CHAR16 *mSymbolTypeStr[] = {
L"( F)",
L"(SF)",
L"(GV)",
@ -112,11 +112,11 @@ EdbSymbolTypeToStr (
IN EFI_DEBUGGER_SYMBOL_TYPE Type
)
{
if (Type < 0 || Type >= EfiDebuggerSymbolTypeMax) {
if ((Type < 0) || (Type >= EfiDebuggerSymbolTypeMax)) {
return L"(?)";
}
return mSymbolTypeStr [Type];
return mSymbolTypeStr[Type];
}
/**
@ -132,18 +132,18 @@ EdbSymbolTypeToStr (
EFI_DEBUG_STATUS
DebuggerDisplaySymbolAccrodingToAddress (
IN UINTN Address,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
)
{
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
UINTN CandidateAddress;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
UINTN CandidateAddress;
//
// Find the nearest symbol address
//
CandidateAddress = EbdFindSymbolAddress (Address, EdbMatchSymbolTypeNearestAddress, &Object, &Entry);
if (CandidateAddress == 0 || CandidateAddress == (UINTN) -1 || Entry == NULL) {
if ((CandidateAddress == 0) || (CandidateAddress == (UINTN)-1) || (Entry == NULL)) {
EDBPrint (L"Symbole at Address not found!\n");
return EFI_DEBUG_CONTINUE;
} else if (Address != CandidateAddress) {
@ -154,10 +154,10 @@ DebuggerDisplaySymbolAccrodingToAddress (
// Display symbol
//
EDBPrint (L"Symbol File Name: %s\n", Object->Name);
if (sizeof(UINTN) == sizeof(UINT64)) {
if (sizeof (UINTN) == sizeof (UINT64)) {
EDBPrint (L" Address Type Symbol\n");
EDBPrint (L" ================== ==== ========\n");
// EDBPrint (L" 0xFFFFFFFF00000000 ( F) TestMain\n");
// EDBPrint (L" 0xFFFFFFFF00000000 ( F) TestMain\n");
EDBPrint (
L" 0x%016lx %s %a\n",
(UINT64)Entry->Rva + Object->BaseAddress,
@ -167,7 +167,7 @@ DebuggerDisplaySymbolAccrodingToAddress (
} else {
EDBPrint (L" Address Type Symbol\n");
EDBPrint (L" ========== ==== ========\n");
// EDBPrint (L" 0xFFFF0000 ( F) TestMain\n");
// EDBPrint (L" 0xFFFF0000 ( F) TestMain\n");
EDBPrint (
L" 0x%08x %s %a\n",
Entry->Rva + Object->BaseAddress,
@ -197,13 +197,13 @@ EFI_DEBUG_STATUS
DebuggerDisplaySymbolAccrodingToName (
IN CHAR16 *SymbolFileName,
IN CHAR16 *SymbolName,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate
)
{
UINTN Index;
UINTN SubIndex;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
UINTN Index;
UINTN SubIndex;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
if (DebuggerPrivate->DebuggerSymbolContext.ObjectCount == 0) {
EDBPrint (L"No Symbol File!\n");
@ -216,7 +216,8 @@ DebuggerDisplaySymbolAccrodingToName (
Object = DebuggerPrivate->DebuggerSymbolContext.Object;
for (Index = 0; Index < DebuggerPrivate->DebuggerSymbolContext.ObjectCount; Index++, Object++) {
if ((SymbolFileName != NULL) &&
(StriCmp (SymbolFileName, Object->Name) != 0)) {
(StriCmp (SymbolFileName, Object->Name) != 0))
{
continue;
}
@ -234,15 +235,16 @@ DebuggerDisplaySymbolAccrodingToName (
EDBPrint (L"No Symbol!\n");
continue;
}
Entry = Object->Entry;
if (sizeof(UINTN) == sizeof(UINT64)) {
if (sizeof (UINTN) == sizeof (UINT64)) {
EDBPrint (L" Address Type Symbol\n");
EDBPrint (L" ================== ==== ========\n");
// EDBPrint (L" 0xFFFFFFFF00000000 ( F) TestMain (EbcTest.obj)\n");
// EDBPrint (L" 0xFFFFFFFF00000000 ( F) TestMain (EbcTest.obj)\n");
} else {
EDBPrint (L" Address Type Symbol\n");
EDBPrint (L" ========== ==== ========\n");
// EDBPrint (L" 0xFFFF0000 ( F) TestMain (EbcTest.obj)\n");
// EDBPrint (L" 0xFFFF0000 ( F) TestMain (EbcTest.obj)\n");
}
//
@ -250,7 +252,8 @@ DebuggerDisplaySymbolAccrodingToName (
//
for (SubIndex = 0; SubIndex < Object->EntryCount; SubIndex++, Entry++) {
if ((SymbolName != NULL) &&
(StrCmpUnicodeAndAscii (SymbolName, Entry->Name) != 0)) {
(StrCmpUnicodeAndAscii (SymbolName, Entry->Name) != 0))
{
continue;
}
@ -258,13 +261,14 @@ DebuggerDisplaySymbolAccrodingToName (
// Break symbol
//
if (((SubIndex % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
(SubIndex != 0)) {
(SubIndex != 0))
{
if (SetPageBreak ()) {
break;
}
}
if (sizeof(UINTN) == sizeof(UINT64)) {
if (sizeof (UINTN) == sizeof (UINT64)) {
EDBPrint (
L" 0x%016lx %s %a (%a)\n",
(UINT64)Entry->Rva + Object->BaseAddress,
@ -304,27 +308,28 @@ DebuggerDisplaySymbolAccrodingToName (
**/
EFI_DEBUG_STATUS
DebuggerListSymbol (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
CHAR16 *SymbolFileName;
CHAR16 *SymbolName;
CHAR16 *CommandStr;
UINTN Address;
CHAR16 *SymbolFileName;
CHAR16 *SymbolName;
CHAR16 *CommandStr;
UINTN Address;
SymbolFileName = NULL;
SymbolName = NULL;
CommandStr = CommandArg;
SymbolName = NULL;
CommandStr = CommandArg;
//
// display symbol according to address
//
if (CommandStr != NULL) {
if ((StriCmp (CommandStr, L"F") != 0) &&
(StriCmp (CommandStr, L"S") != 0)) {
(StriCmp (CommandStr, L"S") != 0))
{
Address = Xtoi (CommandStr);
return DebuggerDisplaySymbolAccrodingToAddress (Address, DebuggerPrivate);
}
@ -341,10 +346,11 @@ DebuggerListSymbol (
return EFI_DEBUG_CONTINUE;
} else {
SymbolFileName = CommandStr;
CommandStr = StrGetNextTokenLine (L" ");
CommandStr = StrGetNextTokenLine (L" ");
}
}
}
//
// Get SymbolName
//
@ -360,6 +366,7 @@ DebuggerListSymbol (
}
}
}
if (CommandStr != NULL) {
EDBPrint (L"Argument error!\n");
return EFI_DEBUG_CONTINUE;
@ -385,22 +392,22 @@ DebuggerListSymbol (
**/
EFI_DEBUG_STATUS
DebuggerLoadSymbol (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN BufferSize;
VOID *Buffer;
EFI_STATUS Status;
CHAR16 *FileName;
CHAR16 *CommandArg2;
BOOLEAN IsLoadCode;
CHAR16 *DirName;
CHAR16 CodFile[EFI_DEBUGGER_SYMBOL_NAME_MAX];
CHAR16 *CodFileName;
UINTN Index;
UINTN BufferSize;
VOID *Buffer;
EFI_STATUS Status;
CHAR16 *FileName;
CHAR16 *CommandArg2;
BOOLEAN IsLoadCode;
CHAR16 *DirName;
CHAR16 CodFile[EFI_DEBUGGER_SYMBOL_NAME_MAX];
CHAR16 *CodFileName;
UINTN Index;
//
// Check the argument
@ -409,7 +416,8 @@ DebuggerLoadSymbol (
EDBPrint (L"SymbolFile not found!\n");
return EFI_DEBUG_CONTINUE;
}
IsLoadCode = FALSE;
IsLoadCode = FALSE;
CommandArg2 = StrGetNextTokenLine (L" ");
if (CommandArg2 != NULL) {
if (StriCmp (CommandArg2, L"a") == 0) {
@ -424,6 +432,7 @@ DebuggerLoadSymbol (
EDBPrint (L"SymbolFile name error!\n");
return EFI_DEBUG_CONTINUE;
}
if (StriCmp (CommandArg + (StrLen (CommandArg) - 4), L".map") != 0) {
EDBPrint (L"SymbolFile name error!\n");
return EFI_DEBUG_CONTINUE;
@ -433,7 +442,7 @@ DebuggerLoadSymbol (
// Read MAP file to memory
//
Status = ReadFileToBuffer (DebuggerPrivate, CommandArg, &BufferSize, &Buffer, TRUE);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"SymbolFile read error!\n");
return EFI_DEBUG_CONTINUE;
}
@ -443,18 +452,19 @@ DebuggerLoadSymbol (
// Load Symbol
//
Status = EdbLoadSymbol (DebuggerPrivate, FileName, BufferSize, Buffer);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"LoadSymbol error!\n");
gBS->FreePool (Buffer);
return EFI_DEBUG_CONTINUE;
}
gBS->FreePool (Buffer);
//
// Patch Symbol for RVA
//
Status = EdbPatchSymbolRVA (DebuggerPrivate, FileName, EdbEbcImageRvaSearchTypeLast);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"PatchSymbol RVA - %r! Using the RVA in symbol file.\n", Status);
} else {
DEBUG ((DEBUG_ERROR, "PatchSymbol RVA successfully!\n"));
@ -468,9 +478,9 @@ DebuggerLoadSymbol (
// load each cod file
//
DirName = GetDirNameFromFullPath (CommandArg);
ZeroMem (CodFile, sizeof(CodFile));
ZeroMem (CodFile, sizeof (CodFile));
if (StrCmp (DirName, L"") != 0) {
StrCpyS (CodFile, sizeof(CodFile), DirName);
StrCpyS (CodFile, sizeof (CodFile), DirName);
} else {
DirName = L"\\";
}
@ -478,19 +488,19 @@ DebuggerLoadSymbol (
//
// Go throuth each file under this dir
//
Index = 0;
Index = 0;
CodFileName = GetFileNameUnderDir (DebuggerPrivate, DirName, L".cod", &Index);
while (CodFileName != NULL) {
ZeroMem (CodFile, sizeof(CodFile));
ZeroMem (CodFile, sizeof (CodFile));
if (StrCmp (DirName, L"\\") != 0) {
StrCpyS (CodFile, sizeof(CodFile), DirName);
StrCpyS (CodFile, sizeof (CodFile), DirName);
}
//
// read cod file to memory
//
Status = ReadFileToBuffer (DebuggerPrivate, ConstructFullPath (CodFile, CodFileName, EFI_DEBUGGER_SYMBOL_NAME_MAX - StrLen (CodFile) - 2), &BufferSize, &Buffer, FALSE);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"CodeFile read error!\n");
CodFileName = GetFileNameUnderDir (DebuggerPrivate, DirName, L".cod", &Index);
continue;
@ -544,19 +554,19 @@ DebuggerLoadSymbol (
**/
EFI_DEBUG_STATUS
DebuggerUnloadSymbol (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
EFI_STATUS Status;
CHAR16 *FileName;
CHAR16 *DirName;
CHAR16 CodFile[EFI_DEBUGGER_SYMBOL_NAME_MAX];
CHAR16 *CodFileName;
UINTN Index;
VOID *BufferPtr;
EFI_STATUS Status;
CHAR16 *FileName;
CHAR16 *DirName;
CHAR16 CodFile[EFI_DEBUGGER_SYMBOL_NAME_MAX];
CHAR16 *CodFileName;
UINTN Index;
VOID *BufferPtr;
//
// Check the argument
@ -572,9 +582,9 @@ DebuggerUnloadSymbol (
// Unload Code
//
DirName = GetDirNameFromFullPath (CommandArg);
ZeroMem (CodFile, sizeof(CodFile));
ZeroMem (CodFile, sizeof (CodFile));
if (StrCmp (DirName, L"") != 0) {
StrCpyS (CodFile, sizeof(CodFile), DirName);
StrCpyS (CodFile, sizeof (CodFile), DirName);
} else {
DirName = L"\\";
}
@ -582,12 +592,12 @@ DebuggerUnloadSymbol (
//
// Go through each file under this dir
//
Index = 0;
Index = 0;
CodFileName = GetFileNameUnderDir (DebuggerPrivate, DirName, L".cod", &Index);
while (CodFileName != NULL) {
ZeroMem (CodFile, sizeof(CodFile));
ZeroMem (CodFile, sizeof (CodFile));
if (StrCmp (DirName, L"\\") != 0) {
StrCpyS (CodFile, sizeof(CodFile), DirName);
StrCpyS (CodFile, sizeof (CodFile), DirName);
}
//
@ -620,7 +630,7 @@ DebuggerUnloadSymbol (
// Unload Symbol
//
Status = EdbUnloadSymbol (DebuggerPrivate, FileName);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"UnloadSymbol error!\n");
}
@ -644,10 +654,10 @@ DebuggerUnloadSymbol (
**/
EFI_DEBUG_STATUS
DebuggerDisplaySymbol (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
if (CommandArg == NULL) {
@ -680,18 +690,18 @@ DebuggerDisplaySymbol (
**/
EFI_DEBUG_STATUS
DebuggerLoadCode (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINTN BufferSize;
VOID *Buffer;
EFI_STATUS Status;
CHAR16 *CommandArg2;
CHAR16 *FileName;
CHAR16 *MapFileName;
UINTN BufferSize;
VOID *Buffer;
EFI_STATUS Status;
CHAR16 *CommandArg2;
CHAR16 *FileName;
CHAR16 *MapFileName;
//
// Check the argument
@ -700,6 +710,7 @@ DebuggerLoadCode (
EDBPrint (L"CodeFile not found!\n");
return EFI_DEBUG_CONTINUE;
}
CommandArg2 = StrGetNextTokenLine (L" ");
if (CommandArg2 == NULL) {
EDBPrint (L"SymbolFile not found!\n");
@ -710,14 +721,17 @@ DebuggerLoadCode (
EDBPrint (L"CodeFile name error!\n");
return EFI_DEBUG_CONTINUE;
}
if (StriCmp (CommandArg + (StrLen (CommandArg) - 4), L".cod") != 0) {
EDBPrint (L"CodeFile name error!\n");
return EFI_DEBUG_CONTINUE;
}
if (StrLen (CommandArg2) <= 4) {
EDBPrint (L"SymbolFile name error!\n");
return EFI_DEBUG_CONTINUE;
}
if (StriCmp (CommandArg2 + (StrLen (CommandArg2) - 4), L".map") != 0) {
EDBPrint (L"SymbolFile name error!\n");
return EFI_DEBUG_CONTINUE;
@ -727,12 +741,12 @@ DebuggerLoadCode (
// read cod file to memory
//
Status = ReadFileToBuffer (DebuggerPrivate, CommandArg, &BufferSize, &Buffer, TRUE);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
EDBPrint (L"CodeFile read error!\n");
return EFI_DEBUG_CONTINUE;
}
FileName = GetFileNameFromFullPath (CommandArg);
FileName = GetFileNameFromFullPath (CommandArg);
MapFileName = GetFileNameFromFullPath (CommandArg2);
//
// Load Code
@ -774,17 +788,17 @@ DebuggerLoadCode (
**/
EFI_DEBUG_STATUS
DebuggerUnloadCode (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
CHAR16 *CommandArg2;
CHAR16 *FileName;
CHAR16 *MapFileName;
EFI_STATUS Status;
VOID *BufferPtr;
CHAR16 *CommandArg2;
CHAR16 *FileName;
CHAR16 *MapFileName;
EFI_STATUS Status;
VOID *BufferPtr;
//
// Check the argument
@ -793,13 +807,14 @@ DebuggerUnloadCode (
EDBPrint (L"CodeFile not found!\n");
return EFI_DEBUG_CONTINUE;
}
CommandArg2 = StrGetNextTokenLine (L" ");
if (CommandArg2 == NULL) {
EDBPrint (L"SymbolFile not found!\n");
return EFI_DEBUG_CONTINUE;
}
FileName = GetFileNameFromFullPath (CommandArg);
FileName = GetFileNameFromFullPath (CommandArg);
MapFileName = GetFileNameFromFullPath (CommandArg2);
//
@ -839,10 +854,10 @@ DebuggerUnloadCode (
**/
EFI_DEBUG_STATUS
DebuggerDisplayCode (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
if (CommandArg == NULL) {

View File

@ -25,7 +25,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Address> - The hexical address user want to break at.\n"
L" <Symbol> - The symbol name for target address user want to break at. It has following format [MapFileName:]SymbolName\n",
L"Execution:\n",
{SCAN_F5, CHAR_NULL},
{ SCAN_F5, CHAR_NULL },
DebuggerGo
},
{
@ -35,7 +35,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"T\n"
L" (No Argument)\n",
L"",
{SCAN_F8, CHAR_NULL},
{ SCAN_F8, CHAR_NULL },
DebuggerStepInto
},
{
@ -45,7 +45,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"P\n"
L" (No Argument)\n",
L"",
{SCAN_F10, CHAR_NULL},
{ SCAN_F10, CHAR_NULL },
DebuggerStepOver
},
{
@ -55,7 +55,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"O\n"
L" (No Argument)\n",
L"",
{SCAN_F11, CHAR_NULL},
{ SCAN_F11, CHAR_NULL },
DebuggerStepOut
},
{
@ -65,7 +65,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"Q\n"
L" (No Argument)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerQuit
},
//
@ -80,7 +80,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable break-on-call\n"
L" off - disable break-on-call\n",
L"Break:\n",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakOnCALL
},
{
@ -92,7 +92,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable break-on-callex\n"
L" off - disable break-on-callex\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakOnCALLEX
},
{
@ -104,7 +104,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable break-on-return\n"
L" off - disable break-on-return\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakOnRET
},
{
@ -116,7 +116,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable break-on-entrypoint\n"
L" off - disable break-on-entrypoint\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakOnEntrypoint
},
{
@ -128,7 +128,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable break-on-thunk\n"
L" off - disable break-on-thunk\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakOnThunk
},
{
@ -140,7 +140,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable break-on-key\n"
L" off - disable break-on-key\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakOnKey
},
{
@ -150,7 +150,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"BL\n"
L" (No Argument) - show the state for current breakpoint\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakpointList
},
{
@ -161,7 +161,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Address> - Hexical breakpoint address\n"
L" <Symbol> - Symbol name for breakpoint address. It has following format [MapFileName:]SymbolName.\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakpointSet
},
{
@ -172,7 +172,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Index> - Decimal breakpoint index, which can be got from BL command\n"
L" * - For all the breakpoint\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakpointClear
},
{
@ -183,7 +183,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Index> - Decimal breakpoint index, which can be got from BL command\n"
L" * - For all the breakpoint\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakpointDisable
},
{
@ -194,7 +194,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Index> - Decimal breakpoint index, which can be got from BL command\n"
L" * - For all the breakpoint\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerBreakpointEnable
},
//
@ -210,7 +210,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" ParameterNum - Decimal call-stack parameters number, 8 by default, 16 as max\n"
L" c - Clear current call-stack\n",
L"Information:\n",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerCallStack
},
{
@ -221,7 +221,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" (No Argument) - Show current instruction branch\n"
L" c - Clear current instruction branch\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerInstructionBranch
},
{
@ -233,7 +233,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Register> - EBC VM register name (R0~R7, Flags, ControlFlags, and IP\n"
L" <Value> - The Hexical value of register\n",
L"",
{SCAN_F2, CHAR_NULL},
{ SCAN_F2, CHAR_NULL },
DebuggerRegister
},
{
@ -244,7 +244,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" (No Argument) - List current assembly code\n"
L" Count - The decimal instruction assembly count\n",
L"",
{SCAN_F4, CHAR_NULL},
{ SCAN_F4, CHAR_NULL },
DebuggerList
},
{
@ -255,7 +255,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Address> - The Hexical address where user wants to see the assembly code\n"
L" <Symbol> - Symbol name for scope address. It has following format [MapFileName:]SymbolName.\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerScope
},
{
@ -267,7 +267,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Count> - The hexical memory count (not set means 1)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryDB
},
{
@ -279,7 +279,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Count> - The hexical memory count (not set means 1)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryDW
},
{
@ -291,7 +291,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Count> - The hexical memory count (not set means 1)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryDD
},
{
@ -303,7 +303,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Count> - The hexical memory count (not set means 1)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryDQ
},
{
@ -315,7 +315,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Value> - The hexical memory value\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryEB
},
{
@ -327,7 +327,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Value> - The hexical memory value\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryEW
},
{
@ -339,7 +339,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Value> - The hexical memory value\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryED
},
{
@ -351,7 +351,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
L" <Value> - The hexical memory value\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerMemoryEQ
},
//
@ -367,7 +367,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" S <Symbol> - List this symbol only\n"
L" <Address> - The hexical memory address, which user want to find the symbol for.\n",
L"Symbol:\n",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerListSymbol
},
{
@ -378,7 +378,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n"
L" a - Automatically load code files in the same dir\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerLoadSymbol
},
{
@ -388,7 +388,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"UNLOADSYMBOL <SymbolFile>\n"
L" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerUnloadSymbol
},
{
@ -399,7 +399,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" CodeFile - The EBC code file (Its name should be XXX.COD)\n"
L" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerLoadCode
},
{
@ -410,7 +410,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" CodeFile - The EBC code file (Its name should be XXX.COD)\n"
L" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n",
L"",
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
DebuggerUnloadCode
},
{
@ -423,7 +423,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable symbol output\n"
L" off - disable symbol output\n",
L"",
{SCAN_F3, CHAR_NULL},
{ SCAN_F3, CHAR_NULL },
DebuggerDisplaySymbol
},
{
@ -436,7 +436,7 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L" on - enable source only output\n"
L" off - disable source only output\n",
L"",
{SCAN_F6, CHAR_NULL},
{ SCAN_F6, CHAR_NULL },
DebuggerDisplayCode
},
//
@ -448,120 +448,121 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
L"The help command will print help information for each command\n\n",
L"H [<Command>]\n",
L"",
{SCAN_F1, CHAR_NULL},
{ SCAN_F1, CHAR_NULL },
DebuggerHelp
},
/*
//
// Extended
//
{
L"!IB",
L"![I|O][B|W|D] - display/modify IO\n",
L"",
L"!IB <Address>\n",
L"Extended:\n",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoIB
},
{
L"!IW",
L"",
L"",
L"!IW <Address>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoIW
},
{
L"!ID",
L"",
L"",
L"!ID <Address>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoID
},
{
L"!OB",
L"",
L"",
L"!OB <Address> <Value>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoOB
},
{
L"!OW",
L"",
L"",
L"!OW <Address> <Value>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoOW
},
{
L"!OD",
L"",
L"",
L"!OD <Address> <Value>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoOD
},
{
L"!PCIL",
L"!PCIL - list PCI device, with BAR\n",
L"",
L"!PCIL [B]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciPCIL
},
{
L"!PCID",
L"!PCID - show PCI space\n",
L"",
L"!PCID Bus Device Function [H|B|E]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciPCID
},
{
L"!CFGB",
L"!CFG[B|W|D] - show/modify PCI space",
L"",
L"!CFGB <Address> [<Value>]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciCFGB
},
{
L"!CFGW",
L"",
L"",
L"!CFGW <Address> [<Value>]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciCFGW
},
{
L"!CFGD",
L"",
L"",
L"!CFGD <Address> [<Value>]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciCFGD
},
*/
/*
//
// Extended
//
{
L"!IB",
L"![I|O][B|W|D] - display/modify IO\n",
L"",
L"!IB <Address>\n",
L"Extended:\n",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoIB
},
{
L"!IW",
L"",
L"",
L"!IW <Address>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoIW
},
{
L"!ID",
L"",
L"",
L"!ID <Address>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoID
},
{
L"!OB",
L"",
L"",
L"!OB <Address> <Value>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoOB
},
{
L"!OW",
L"",
L"",
L"!OW <Address> <Value>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoOW
},
{
L"!OD",
L"",
L"",
L"!OD <Address> <Value>\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtIoOD
},
{
L"!PCIL",
L"!PCIL - list PCI device, with BAR\n",
L"",
L"!PCIL [B]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciPCIL
},
{
L"!PCID",
L"!PCID - show PCI space\n",
L"",
L"!PCID Bus Device Function [H|B|E]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciPCID
},
{
L"!CFGB",
L"!CFG[B|W|D] - show/modify PCI space",
L"",
L"!CFGB <Address> [<Value>]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciCFGB
},
{
L"!CFGW",
L"",
L"",
L"!CFGW <Address> [<Value>]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciCFGW
},
{
L"!CFGD",
L"",
L"",
L"!CFGD <Address> [<Value>]\n",
L"",
{SCAN_NULL, CHAR_NULL},
DebuggerExtPciCFGD
},
*/
{
NULL,
NULL,
NULL,
NULL,
NULL,
{SCAN_NULL, CHAR_NULL},
{ SCAN_NULL, CHAR_NULL },
NULL
},
};
@ -579,22 +580,22 @@ EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet[] = {
**/
EFI_DEBUGGER_COMMAND
MatchDebuggerCommand (
IN CHAR16 *CommandName,
IN CHAR16 **CommandArg
IN CHAR16 *CommandName,
IN CHAR16 **CommandArg
)
{
UINTN Index;
CHAR16 *Temp;
UINTN Index;
CHAR16 *Temp;
//
// Get Command Name
//
Temp = StrGetNewTokenLine (CommandName, L" ");
Temp = StrGetNewTokenLine (CommandName, L" ");
CommandName = Temp;
//
// Get Command Argument
//
Temp = StrGetNextTokenLine (L" ");
Temp = StrGetNextTokenLine (L" ");
*CommandArg = Temp;
if (CommandName == NULL) {
@ -631,7 +632,7 @@ MatchDebuggerCommand (
**/
CHAR16 *
GetCommandNameByKey (
IN EFI_INPUT_KEY CommandKey
IN EFI_INPUT_KEY CommandKey
)
{
UINTN Index;
@ -641,7 +642,8 @@ GetCommandNameByKey (
//
for (Index = 0; mDebuggerCommandSet[Index].CommandName != NULL; Index++) {
if ((mDebuggerCommandSet[Index].CommandKey.UnicodeChar == CommandKey.UnicodeChar) &&
(mDebuggerCommandSet[Index].CommandKey.ScanCode == CommandKey.ScanCode)) {
(mDebuggerCommandSet[Index].CommandKey.ScanCode == CommandKey.ScanCode))
{
//
// Found
//

View File

@ -30,8 +30,8 @@ typedef enum {
**/
EFI_DEBUGGER_COMMAND
MatchDebuggerCommand (
IN CHAR16 *CommandName,
IN CHAR16 **CommandArg
IN CHAR16 *CommandName,
IN CHAR16 **CommandArg
);
/**
@ -46,7 +46,7 @@ MatchDebuggerCommand (
**/
CHAR16 *
GetCommandNameByKey (
IN EFI_INPUT_KEY CommandKey
IN EFI_INPUT_KEY CommandKey
);
//

View File

@ -34,29 +34,29 @@ typedef struct _EFI_DEBUGGER_PRIVATE_DATA EFI_DEBUGGER_PRIVATE_DATA;
//
typedef
EFI_DEBUG_STATUS
(* EFI_DEBUGGER_COMMAND) (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
);
(*EFI_DEBUGGER_COMMAND) (
IN CHAR16 *CommandArg,
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT SystemContext
);
typedef struct {
CHAR16 *CommandName;
CHAR16 *CommandTitle;
CHAR16 *CommandHelp;
CHAR16 *CommandSyntax;
CHAR16 *ClassName;
EFI_INPUT_KEY CommandKey;
EFI_DEBUGGER_COMMAND CommandFunc;
CHAR16 *CommandName;
CHAR16 *CommandTitle;
CHAR16 *CommandHelp;
CHAR16 *CommandSyntax;
CHAR16 *ClassName;
EFI_INPUT_KEY CommandKey;
EFI_DEBUGGER_COMMAND CommandFunc;
} EFI_DEBUGGER_COMMAND_SET;
//
// Definition for Debugger Symbol
//
#define EFI_DEBUGGER_SYMBOL_NAME_MAX 256
#define EFI_DEBUGGER_SYMBOL_ENTRY_MAX 512
#define EFI_DEBUGGER_SYMBOL_OBJECT_MAX 32
#define EFI_DEBUGGER_SYMBOL_NAME_MAX 256
#define EFI_DEBUGGER_SYMBOL_ENTRY_MAX 512
#define EFI_DEBUGGER_SYMBOL_OBJECT_MAX 32
//
// We have following SYMBOL data structure:
@ -81,50 +81,50 @@ typedef enum {
} EFI_DEBUGGER_SYMBOL_TYPE;
typedef struct {
CHAR8 Name[EFI_DEBUGGER_SYMBOL_NAME_MAX];
UINTN Rva;
EFI_DEBUGGER_SYMBOL_TYPE Type;
CHAR8 ObjName[EFI_DEBUGGER_SYMBOL_NAME_MAX];
CHAR8 *CodBuffer;
UINTN CodBufferSize;
UINTN FuncOffsetBase;
CHAR8 *SourceBuffer;
CHAR8 Name[EFI_DEBUGGER_SYMBOL_NAME_MAX];
UINTN Rva;
EFI_DEBUGGER_SYMBOL_TYPE Type;
CHAR8 ObjName[EFI_DEBUGGER_SYMBOL_NAME_MAX];
CHAR8 *CodBuffer;
UINTN CodBufferSize;
UINTN FuncOffsetBase;
CHAR8 *SourceBuffer;
} EFI_DEBUGGER_SYMBOL_ENTRY;
typedef struct {
CHAR16 Name[EFI_DEBUGGER_SYMBOL_NAME_MAX];
UINTN EntryCount;
UINTN MaxEntryCount;
UINTN BaseAddress;
UINTN StartEntrypointRVA;
UINTN MainEntrypointRVA;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
VOID **SourceBuffer;
CHAR16 Name[EFI_DEBUGGER_SYMBOL_NAME_MAX];
UINTN EntryCount;
UINTN MaxEntryCount;
UINTN BaseAddress;
UINTN StartEntrypointRVA;
UINTN MainEntrypointRVA;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
VOID **SourceBuffer;
} EFI_DEBUGGER_SYMBOL_OBJECT;
typedef struct {
UINTN ObjectCount;
UINTN MaxObjectCount;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
BOOLEAN DisplaySymbol;
BOOLEAN DisplayCodeOnly;
UINTN ObjectCount;
UINTN MaxObjectCount;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
BOOLEAN DisplaySymbol;
BOOLEAN DisplayCodeOnly;
} EFI_DEBUGGER_SYMBOL_CONTEXT;
//
// Definition for Debugger Breakpoint
//
#define EFI_DEBUGGER_BREAKPOINT_MAX 0x10
#define EFI_DEBUGGER_BREAKPOINT_MAX 0x10
typedef struct {
EFI_PHYSICAL_ADDRESS BreakpointAddress;
UINT64 OldInstruction; // UINT64 is enough for an instruction
BOOLEAN State;
EFI_PHYSICAL_ADDRESS BreakpointAddress;
UINT64 OldInstruction; // UINT64 is enough for an instruction
BOOLEAN State;
} EFI_DEBUGGER_BREAKPOINT_CONTEXT;
//
// Definition for Debugger Call-Stack
//
#define EFI_DEBUGGER_CALLSTACK_MAX 0x10
#define EFI_DEBUGGER_CALLSTACK_MAX 0x10
typedef enum {
EfiDebuggerBranchTypeEbcCall,
@ -139,101 +139,101 @@ typedef enum {
#define EFI_DEBUGGER_CALL_DEFAULT_PARAMETER 0x8
typedef struct {
EFI_PHYSICAL_ADDRESS SourceAddress;
EFI_PHYSICAL_ADDRESS DestAddress;
EFI_PHYSICAL_ADDRESS SourceAddress;
EFI_PHYSICAL_ADDRESS DestAddress;
//
// We save all parameter here, because code may update the parameter as local variable.
//
UINTN ParameterAddr;
UINTN Parameter[EFI_DEBUGGER_CALL_MAX_PARAMETER];
EFI_DEBUGGER_BRANCH_TYPE Type;
UINTN ParameterAddr;
UINTN Parameter[EFI_DEBUGGER_CALL_MAX_PARAMETER];
EFI_DEBUGGER_BRANCH_TYPE Type;
} EFI_DEBUGGER_CALLSTACK_CONTEXT;
//
// Definition for Debugger Trace
//
#define EFI_DEBUGGER_TRACE_MAX 0x10
#define EFI_DEBUGGER_TRACE_MAX 0x10
typedef struct {
EFI_PHYSICAL_ADDRESS SourceAddress;
EFI_PHYSICAL_ADDRESS DestAddress;
EFI_DEBUGGER_BRANCH_TYPE Type;
EFI_PHYSICAL_ADDRESS SourceAddress;
EFI_PHYSICAL_ADDRESS DestAddress;
EFI_DEBUGGER_BRANCH_TYPE Type;
} EFI_DEBUGGER_TRACE_CONTEXT;
//
// Definition for Debugger Step
//
typedef struct {
EFI_PHYSICAL_ADDRESS BreakAddress;
EFI_PHYSICAL_ADDRESS FramePointer;
EFI_PHYSICAL_ADDRESS BreakAddress;
EFI_PHYSICAL_ADDRESS FramePointer;
} EFI_DEBUGGER_STEP_CONTEXT;
//
// Definition for Debugger GoTil
//
typedef struct {
EFI_PHYSICAL_ADDRESS BreakAddress;
EFI_PHYSICAL_ADDRESS BreakAddress;
} EFI_DEBUGGER_GOTIL_CONTEXT;
//
// Definition for Debugger private data structure
//
#define EFI_DEBUGGER_SIGNATURE SIGNATURE_32 ('e', 'd', 'b', '!')
#define EFI_DEBUGGER_SIGNATURE SIGNATURE_32 ('e', 'd', 'b', '!')
#define EFI_DEBUG_DEFAULT_INSTRUCTION_NUMBER 5
#define EFI_DEBUG_BREAK_TIMER_INTERVAL 10000000 // 1 second
#define EFI_DEBUG_BREAK_TIMER_INTERVAL 10000000 // 1 second
#define EFI_DEBUG_FLAG_EBC 0x80000000
#define EFI_DEBUG_FLAG_EBC_B_BOC 0x1
#define EFI_DEBUG_FLAG_EBC_B_BOCX 0x2
#define EFI_DEBUG_FLAG_EBC_B_BOR 0x4
#define EFI_DEBUG_FLAG_EBC_B_BOE 0x8
#define EFI_DEBUG_FLAG_EBC_B_BOT 0x10
#define EFI_DEBUG_FLAG_EBC_B_STEPOVER 0x20
#define EFI_DEBUG_FLAG_EBC_B_STEPOUT 0x40
#define EFI_DEBUG_FLAG_EBC_B_BP 0x80
#define EFI_DEBUG_FLAG_EBC_B_GT 0x100
#define EFI_DEBUG_FLAG_EBC_B_BOK 0x200
#define EFI_DEBUG_FLAG_EBC_BOC (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOC)
#define EFI_DEBUG_FLAG_EBC_BOCX (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOCX)
#define EFI_DEBUG_FLAG_EBC_BOR (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOR)
#define EFI_DEBUG_FLAG_EBC_BOE (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOE)
#define EFI_DEBUG_FLAG_EBC_BOT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOT)
#define EFI_DEBUG_FLAG_EBC_STEPOVER (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_STEPOVER)
#define EFI_DEBUG_FLAG_EBC_STEPOUT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_STEPOUT)
#define EFI_DEBUG_FLAG_EBC_BP (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BP)
#define EFI_DEBUG_FLAG_EBC_GT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_GT)
#define EFI_DEBUG_FLAG_EBC_BOK (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOK)
#define EFI_DEBUG_FLAG_EBC 0x80000000
#define EFI_DEBUG_FLAG_EBC_B_BOC 0x1
#define EFI_DEBUG_FLAG_EBC_B_BOCX 0x2
#define EFI_DEBUG_FLAG_EBC_B_BOR 0x4
#define EFI_DEBUG_FLAG_EBC_B_BOE 0x8
#define EFI_DEBUG_FLAG_EBC_B_BOT 0x10
#define EFI_DEBUG_FLAG_EBC_B_STEPOVER 0x20
#define EFI_DEBUG_FLAG_EBC_B_STEPOUT 0x40
#define EFI_DEBUG_FLAG_EBC_B_BP 0x80
#define EFI_DEBUG_FLAG_EBC_B_GT 0x100
#define EFI_DEBUG_FLAG_EBC_B_BOK 0x200
#define EFI_DEBUG_FLAG_EBC_BOC (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOC)
#define EFI_DEBUG_FLAG_EBC_BOCX (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOCX)
#define EFI_DEBUG_FLAG_EBC_BOR (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOR)
#define EFI_DEBUG_FLAG_EBC_BOE (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOE)
#define EFI_DEBUG_FLAG_EBC_BOT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOT)
#define EFI_DEBUG_FLAG_EBC_STEPOVER (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_STEPOVER)
#define EFI_DEBUG_FLAG_EBC_STEPOUT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_STEPOUT)
#define EFI_DEBUG_FLAG_EBC_BP (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BP)
#define EFI_DEBUG_FLAG_EBC_GT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_GT)
#define EFI_DEBUG_FLAG_EBC_BOK (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOK)
//
// Debugger private data structure
//
typedef struct _EFI_DEBUGGER_PRIVATE_DATA {
UINT32 Signature;
EFI_INSTRUCTION_SET_ARCHITECTURE Isa;
UINT32 EfiDebuggerRevision;
UINT32 EbcVmRevision;
EFI_DEBUGGER_CONFIGURATION_PROTOCOL DebuggerConfiguration;
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugImageInfoTableHeader;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_DEBUGGER_COMMAND_SET *DebuggerCommandSet;
EFI_DEBUGGER_SYMBOL_CONTEXT DebuggerSymbolContext;
UINTN DebuggerBreakpointCount;
EFI_DEBUGGER_BREAKPOINT_CONTEXT DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX + 1];
UINTN CallStackEntryCount;
EFI_DEBUGGER_CALLSTACK_CONTEXT CallStackEntry[EFI_DEBUGGER_CALLSTACK_MAX + 1];
UINTN TraceEntryCount;
EFI_DEBUGGER_TRACE_CONTEXT TraceEntry[EFI_DEBUGGER_TRACE_MAX + 1];
EFI_DEBUGGER_STEP_CONTEXT StepContext;
EFI_DEBUGGER_GOTIL_CONTEXT GoTilContext;
EFI_PHYSICAL_ADDRESS InstructionScope;
UINTN InstructionNumber;
UINT32 FeatureFlags;
UINT32 StatusFlags;
BOOLEAN EnablePageBreak;
EFI_EVENT BreakEvent;
UINT32 Signature;
EFI_INSTRUCTION_SET_ARCHITECTURE Isa;
UINT32 EfiDebuggerRevision;
UINT32 EbcVmRevision;
EFI_DEBUGGER_CONFIGURATION_PROTOCOL DebuggerConfiguration;
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugImageInfoTableHeader;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_DEBUGGER_COMMAND_SET *DebuggerCommandSet;
EFI_DEBUGGER_SYMBOL_CONTEXT DebuggerSymbolContext;
UINTN DebuggerBreakpointCount;
EFI_DEBUGGER_BREAKPOINT_CONTEXT DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX + 1];
UINTN CallStackEntryCount;
EFI_DEBUGGER_CALLSTACK_CONTEXT CallStackEntry[EFI_DEBUGGER_CALLSTACK_MAX + 1];
UINTN TraceEntryCount;
EFI_DEBUGGER_TRACE_CONTEXT TraceEntry[EFI_DEBUGGER_TRACE_MAX + 1];
EFI_DEBUGGER_STEP_CONTEXT StepContext;
EFI_DEBUGGER_GOTIL_CONTEXT GoTilContext;
EFI_PHYSICAL_ADDRESS InstructionScope;
UINTN InstructionNumber;
UINT32 FeatureFlags;
UINT32 StatusFlags;
BOOLEAN EnablePageBreak;
EFI_EVENT BreakEvent;
} EFI_DEBUGGER_PRIVATE_DATA;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -21,10 +21,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
typedef
UINTN
(* EDB_DISASM_INSTRUCTION) (
IN EFI_PHYSICAL_ADDRESS InstructionAddress,
IN EFI_SYSTEM_CONTEXT SystemContext,
OUT CHAR16 **DisAsmString
(*EDB_DISASM_INSTRUCTION) (
IN EFI_PHYSICAL_ADDRESS InstructionAddress,
IN EFI_SYSTEM_CONTEXT SystemContext,
OUT CHAR16 **DisAsmString
);
#endif

View File

@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Edb.h"
extern EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[];
extern EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[];
typedef struct {
CHAR16 Name[EDB_INSTRUCTION_NAME_MAX_LENGTH];
@ -16,9 +16,9 @@ typedef struct {
CHAR16 Tail;
} EDB_INSTRUCTION_STRING;
EDB_INSTRUCTION_STRING mInstructionString;
UINTN mInstructionNameOffset;
UINTN mInstructionContentOffset;
EDB_INSTRUCTION_STRING mInstructionString;
UINTN mInstructionNameOffset;
UINTN mInstructionContentOffset;
/**
@ -30,14 +30,14 @@ UINTN mInstructionContentOffset;
**/
VOID
EdbSetOffset (
IN UINTN InstructionNameOffset,
IN UINTN InstructionContentOffset
IN UINTN InstructionNameOffset,
IN UINTN InstructionContentOffset
)
{
mInstructionNameOffset = InstructionNameOffset;
mInstructionNameOffset = InstructionNameOffset;
mInstructionContentOffset = InstructionContentOffset;
return ;
return;
}
/**
@ -52,7 +52,7 @@ EdbPreInstructionString (
VOID
)
{
ZeroMem (&mInstructionString, sizeof(mInstructionString));
ZeroMem (&mInstructionString, sizeof (mInstructionString));
mInstructionNameOffset = 0;
mInstructionContentOffset = 0;
@ -71,13 +71,14 @@ EdbPostInstructionString (
VOID
)
{
CHAR16 *Char;
CHAR16 *Char;
for (Char = (CHAR16 *)&mInstructionString; Char < &mInstructionString.Tail; Char++) {
if (*Char == 0) {
*Char = L' ';
}
}
mInstructionString.Tail = 0;
mInstructionNameOffset = 0;
@ -104,15 +105,15 @@ EdbGetNaturalIndex16 (
OUT UINTN *ConstantUnits
)
{
BOOLEAN Sign;
UINTN NaturalUnitBit;
BOOLEAN Sign;
UINTN NaturalUnitBit;
Sign = (BOOLEAN)(Data16 >> 15);
NaturalUnitBit = (UINTN)((Data16 >> 12) & 0x7);
Sign = (BOOLEAN)(Data16 >> 15);
NaturalUnitBit = (UINTN)((Data16 >> 12) & 0x7);
NaturalUnitBit *= 2;
Data16 = Data16 & 0xFFF;
*NaturalUnits = (UINTN)(Data16 & ((1 << NaturalUnitBit) - 1));
*ConstantUnits = (UINTN)((Data16 >> NaturalUnitBit) & ((1 << (12 - NaturalUnitBit)) - 1));
Data16 = Data16 & 0xFFF;
*NaturalUnits = (UINTN)(Data16 & ((1 << NaturalUnitBit) - 1));
*ConstantUnits = (UINTN)((Data16 >> NaturalUnitBit) & ((1 << (12 - NaturalUnitBit)) - 1));
return Sign;
}
@ -135,15 +136,15 @@ EdbGetNaturalIndex32 (
OUT UINTN *ConstantUnits
)
{
BOOLEAN Sign;
UINTN NaturalUnitBit;
BOOLEAN Sign;
UINTN NaturalUnitBit;
Sign = (BOOLEAN)(Data32 >> 31);
NaturalUnitBit = (UINTN)((Data32 >> 28) & 0x7);
Sign = (BOOLEAN)(Data32 >> 31);
NaturalUnitBit = (UINTN)((Data32 >> 28) & 0x7);
NaturalUnitBit *= 4;
Data32 = Data32 & 0xFFFFFFF;
*NaturalUnits = (UINTN)(Data32 & ((1 << NaturalUnitBit) - 1));
*ConstantUnits = (UINTN)((Data32 >> NaturalUnitBit) & ((1 << (28 - NaturalUnitBit)) - 1));
Data32 = Data32 & 0xFFFFFFF;
*NaturalUnits = (UINTN)(Data32 & ((1 << NaturalUnitBit) - 1));
*ConstantUnits = (UINTN)((Data32 >> NaturalUnitBit) & ((1 << (28 - NaturalUnitBit)) - 1));
return Sign;
}
@ -166,15 +167,15 @@ EdbGetNaturalIndex64 (
OUT UINT64 *ConstantUnits
)
{
BOOLEAN Sign;
UINTN NaturalUnitBit;
BOOLEAN Sign;
UINTN NaturalUnitBit;
Sign = (BOOLEAN)RShiftU64 (Data64, 63);
NaturalUnitBit = (UINTN)(RShiftU64 (Data64, 60) & 0x7);
Sign = (BOOLEAN)RShiftU64 (Data64, 63);
NaturalUnitBit = (UINTN)(RShiftU64 (Data64, 60) & 0x7);
NaturalUnitBit *= 8;
Data64 = RShiftU64 (LShiftU64 (Data64, 4), 4);
*NaturalUnits = (UINT64)(Data64 & (LShiftU64 (1, NaturalUnitBit) - 1));
*ConstantUnits = (UINT64)(RShiftU64 (Data64, NaturalUnitBit) & (LShiftU64 (1, (60 - NaturalUnitBit)) - 1));
Data64 = RShiftU64 (LShiftU64 (Data64, 4), 4);
*NaturalUnits = (UINT64)(Data64 & (LShiftU64 (1, NaturalUnitBit) - 1));
*ConstantUnits = (UINT64)(RShiftU64 (Data64, NaturalUnitBit) & (LShiftU64 (1, (60 - NaturalUnitBit)) - 1));
return Sign;
}
@ -235,7 +236,7 @@ EdbGetBitWidth (
**/
UINTN
EdbPrintInstructionName (
IN CHAR16 *Name
IN CHAR16 *Name
)
{
EDBSPrintWithOffset (
@ -261,7 +262,7 @@ EdbPrintInstructionName (
**/
UINTN
EdbPrintRegister1 (
IN UINT8 Operands
IN UINT8 Operands
)
{
if ((Operands & OPERAND_M_INDIRECT1) != 0) {
@ -273,6 +274,7 @@ EdbPrintRegister1 (
);
mInstructionContentOffset += 1;
}
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
@ -296,7 +298,7 @@ EdbPrintRegister1 (
**/
UINTN
EdbPrintRegister2 (
IN UINT8 Operands
IN UINT8 Operands
)
{
if ((Operands & OPERAND_M_INDIRECT2) != 0) {
@ -308,6 +310,7 @@ EdbPrintRegister2 (
);
mInstructionContentOffset += 1;
}
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
@ -331,28 +334,28 @@ EdbPrintRegister2 (
**/
UINTN
EdbPrintDedicatedRegister1 (
IN UINT8 Operands
IN UINT8 Operands
)
{
switch (Operands & OPERAND_M_OP1) {
case 0:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[FLAGS]"
);
mInstructionContentOffset += 7;
break;
case 1:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[IP]"
);
mInstructionContentOffset += 4;
break;
case 0:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[FLAGS]"
);
mInstructionContentOffset += 7;
break;
case 1:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[IP]"
);
mInstructionContentOffset += 4;
break;
}
return mInstructionContentOffset;
@ -369,28 +372,28 @@ EdbPrintDedicatedRegister1 (
**/
UINTN
EdbPrintDedicatedRegister2 (
IN UINT8 Operands
IN UINT8 Operands
)
{
switch ((Operands & OPERAND_M_OP2) >> 4) {
case 0:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[FLAGS]"
);
mInstructionContentOffset += 7;
break;
case 1:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[IP]"
);
mInstructionContentOffset += 4;
break;
case 0:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[FLAGS]"
);
mInstructionContentOffset += 7;
break;
case 1:
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"[IP]"
);
mInstructionContentOffset += 4;
break;
}
return mInstructionContentOffset;
@ -409,9 +412,9 @@ EdbPrintDedicatedRegister2 (
**/
UINTN
EdbPrintIndexData (
IN BOOLEAN Sign,
IN UINTN NaturalUnits,
IN UINTN ConstantUnits
IN BOOLEAN Sign,
IN UINTN NaturalUnits,
IN UINTN ConstantUnits
)
{
EDBSPrintWithOffset (
@ -424,7 +427,7 @@ EdbPrintIndexData (
Sign ? L"-" : L"+",
ConstantUnits
);
mInstructionContentOffset = mInstructionContentOffset + 5 + EdbGetBitWidth (NaturalUnits) + EdbGetBitWidth (ConstantUnits);
mInstructionContentOffset = mInstructionContentOffset + 5 + EdbGetBitWidth (NaturalUnits) + EdbGetBitWidth (ConstantUnits);
return mInstructionContentOffset;
}
@ -442,9 +445,9 @@ EdbPrintIndexData (
**/
UINTN
EdbPrintIndexData64 (
IN BOOLEAN Sign,
IN UINT64 NaturalUnits,
IN UINT64 ConstantUnits
IN BOOLEAN Sign,
IN UINT64 NaturalUnits,
IN UINT64 ConstantUnits
)
{
EDBSPrintWithOffset (
@ -457,7 +460,7 @@ EdbPrintIndexData64 (
Sign ? L"-" : L"+",
ConstantUnits
);
mInstructionContentOffset = mInstructionContentOffset + 5 + EdbGetBitWidth (NaturalUnits) + EdbGetBitWidth (ConstantUnits);
mInstructionContentOffset = mInstructionContentOffset + 5 + EdbGetBitWidth (NaturalUnits) + EdbGetBitWidth (ConstantUnits);
return mInstructionContentOffset;
}
@ -473,15 +476,15 @@ EdbPrintIndexData64 (
**/
UINTN
EdbPrintRawIndexData16 (
IN UINT16 Data16
IN UINT16 Data16
)
{
BOOLEAN Sign;
UINTN NaturalUnits;
UINTN ConstantUnits;
UINTN Offset;
BOOLEAN Sign;
UINTN NaturalUnits;
UINTN ConstantUnits;
UINTN Offset;
Sign = EdbGetNaturalIndex16 (Data16, &NaturalUnits, &ConstantUnits);
Sign = EdbGetNaturalIndex16 (Data16, &NaturalUnits, &ConstantUnits);
Offset = EdbPrintIndexData (Sign, NaturalUnits, ConstantUnits);
return Offset;
@ -498,15 +501,15 @@ EdbPrintRawIndexData16 (
**/
UINTN
EdbPrintRawIndexData32 (
IN UINT32 Data32
IN UINT32 Data32
)
{
BOOLEAN Sign;
UINTN NaturalUnits;
UINTN ConstantUnits;
UINTN Offset;
BOOLEAN Sign;
UINTN NaturalUnits;
UINTN ConstantUnits;
UINTN Offset;
Sign = EdbGetNaturalIndex32 (Data32, &NaturalUnits, &ConstantUnits);
Sign = EdbGetNaturalIndex32 (Data32, &NaturalUnits, &ConstantUnits);
Offset = EdbPrintIndexData (Sign, NaturalUnits, ConstantUnits);
return Offset;
@ -523,15 +526,15 @@ EdbPrintRawIndexData32 (
**/
UINTN
EdbPrintRawIndexData64 (
IN UINT64 Data64
IN UINT64 Data64
)
{
BOOLEAN Sign;
UINT64 NaturalUnits;
UINT64 ConstantUnits;
UINTN Offset;
BOOLEAN Sign;
UINT64 NaturalUnits;
UINT64 ConstantUnits;
UINTN Offset;
Sign = EdbGetNaturalIndex64 (Data64, &NaturalUnits, &ConstantUnits);
Sign = EdbGetNaturalIndex64 (Data64, &NaturalUnits, &ConstantUnits);
Offset = EdbPrintIndexData64 (Sign, NaturalUnits, ConstantUnits);
return Offset;
@ -548,7 +551,7 @@ EdbPrintRawIndexData64 (
**/
UINTN
EdbPrintImmData8 (
IN UINT8 Data
IN UINT8 Data
)
{
EDBSPrintWithOffset (
@ -558,7 +561,7 @@ EdbPrintImmData8 (
L"(0x%02x)",
(UINTN)Data
);
mInstructionContentOffset += 6;
mInstructionContentOffset += 6;
return mInstructionContentOffset;
}
@ -574,7 +577,7 @@ EdbPrintImmData8 (
**/
UINTN
EdbPrintImmData16 (
IN UINT16 Data
IN UINT16 Data
)
{
EDBSPrintWithOffset (
@ -584,7 +587,7 @@ EdbPrintImmData16 (
L"(0x%04x)",
(UINTN)Data
);
mInstructionContentOffset += 8;
mInstructionContentOffset += 8;
return mInstructionContentOffset;
}
@ -600,7 +603,7 @@ EdbPrintImmData16 (
**/
UINTN
EdbPrintImmData32 (
IN UINT32 Data
IN UINT32 Data
)
{
EDBSPrintWithOffset (
@ -610,7 +613,7 @@ EdbPrintImmData32 (
L"(0x%08x)",
(UINTN)Data
);
mInstructionContentOffset += 12;
mInstructionContentOffset += 12;
return mInstructionContentOffset;
}
@ -626,7 +629,7 @@ EdbPrintImmData32 (
**/
UINTN
EdbPrintImmData64 (
IN UINT64 Data
IN UINT64 Data
)
{
EDBSPrintWithOffset (
@ -636,7 +639,7 @@ EdbPrintImmData64 (
L"(0x%016lx)",
Data
);
mInstructionContentOffset += 20;
mInstructionContentOffset += 20;
return mInstructionContentOffset;
}
@ -652,7 +655,7 @@ EdbPrintImmData64 (
**/
UINTN
EdbPrintImmDatan (
IN UINTN Data
IN UINTN Data
)
{
EDBSPrintWithOffset (
@ -662,7 +665,7 @@ EdbPrintImmDatan (
L"(%d)",
(UINTN)Data
);
mInstructionContentOffset = mInstructionContentOffset + 2 + EdbGetBitWidth (Data);
mInstructionContentOffset = mInstructionContentOffset + 2 + EdbGetBitWidth (Data);
return mInstructionContentOffset;
}
@ -678,7 +681,7 @@ EdbPrintImmDatan (
**/
UINTN
EdbPrintImmData64n (
IN UINT64 Data64
IN UINT64 Data64
)
{
EDBSPrintWithOffset (
@ -688,7 +691,7 @@ EdbPrintImmData64n (
L"(%ld)",
Data64
);
mInstructionContentOffset = mInstructionContentOffset + 2 + EdbGetBitWidth (Data64);
mInstructionContentOffset = mInstructionContentOffset + 2 + EdbGetBitWidth (Data64);
return mInstructionContentOffset;
}
@ -704,7 +707,7 @@ EdbPrintImmData64n (
**/
UINTN
EdbPrintData8 (
IN UINT8 Data8
IN UINT8 Data8
)
{
EDBSPrintWithOffset (
@ -730,7 +733,7 @@ EdbPrintData8 (
**/
UINTN
EdbPrintData16 (
IN UINT16 Data16
IN UINT16 Data16
)
{
EDBSPrintWithOffset (
@ -756,7 +759,7 @@ EdbPrintData16 (
**/
UINTN
EdbPrintData32 (
IN UINT32 Data32
IN UINT32 Data32
)
{
EDBSPrintWithOffset (
@ -782,7 +785,7 @@ EdbPrintData32 (
**/
UINTN
EdbPrintData64 (
IN UINT64 Data64
IN UINT64 Data64
)
{
EDBSPrintWithOffset (
@ -808,7 +811,7 @@ EdbPrintData64 (
**/
UINTN
EdbPrintDatan (
IN UINTN Data
IN UINTN Data
)
{
EDBSPrintWithOffset (
@ -834,7 +837,7 @@ EdbPrintDatan (
**/
UINTN
EdbPrintData64n (
IN UINT64 Data64
IN UINT64 Data64
)
{
EDBSPrintWithOffset (
@ -860,10 +863,10 @@ EdbPrintData64n (
**/
UINTN
EdbPrintData8s (
IN UINT8 Data8
IN UINT8 Data8
)
{
BOOLEAN Sign;
BOOLEAN Sign;
Sign = (BOOLEAN)(Data8 >> 7);
@ -891,10 +894,10 @@ EdbPrintData8s (
**/
UINTN
EdbPrintData16s (
IN UINT16 Data16
IN UINT16 Data16
)
{
BOOLEAN Sign;
BOOLEAN Sign;
Sign = (BOOLEAN)(Data16 >> 15);
@ -922,10 +925,10 @@ EdbPrintData16s (
**/
UINTN
EdbPrintData32s (
IN UINT32 Data32
IN UINT32 Data32
)
{
BOOLEAN Sign;
BOOLEAN Sign;
Sign = (BOOLEAN)(Data32 >> 31);
@ -953,13 +956,13 @@ EdbPrintData32s (
**/
UINTN
EdbPrintData64s (
IN UINT64 Data64
IN UINT64 Data64
)
{
BOOLEAN Sign;
INT64 Data64s;
BOOLEAN Sign;
INT64 Data64s;
Sign = (BOOLEAN)RShiftU64 (Data64, 63);
Sign = (BOOLEAN)RShiftU64 (Data64, 63);
Data64s = (INT64)RShiftU64 (LShiftU64 (Data64, 1), 1);
EDBSPrintWithOffset (
@ -1010,10 +1013,10 @@ EdbPrintComma (
**/
UINTN
EdbFindAndPrintSymbol (
IN UINTN Address
IN UINTN Address
)
{
CHAR8 *SymbolStr;
CHAR8 *SymbolStr;
SymbolStr = FindSymbolStr (Address);
if (SymbolStr != NULL) {
@ -1040,8 +1043,8 @@ EdbFindAndPrintSymbol (
**/
VOID
EdbPrintRaw (
IN EFI_PHYSICAL_ADDRESS InstructionAddress,
IN UINTN InstructionNumber
IN EFI_PHYSICAL_ADDRESS InstructionAddress,
IN UINTN InstructionNumber
)
{
UINTN LineNumber;
@ -1051,7 +1054,7 @@ EdbPrintRaw (
CHAR8 *SymbolStr;
if (InstructionNumber == 0) {
return ;
return;
}
LineNumber = InstructionNumber / EDB_BYTECODE_NUMBER_IN_LINE;
@ -1075,6 +1078,7 @@ EdbPrintRaw (
EDBPrint (L"%02x ", *(UINT8 *)(UINTN)InstructionAddress);
InstructionAddress += 1;
}
EDBPrint (L"\n");
}
@ -1083,11 +1087,12 @@ EdbPrintRaw (
EDBPrint (L"%02x ", *(UINT8 *)(UINTN)InstructionAddress);
InstructionAddress += 1;
}
for (ByteIndex = 0; ByteIndex < EDB_BYTECODE_NUMBER_IN_LINE - ByteNumber; ByteIndex++) {
EDBPrint (L" ");
}
return ;
return;
}
/**
@ -1102,42 +1107,41 @@ EdbPrintRaw (
**/
EFI_STATUS
EdbShowDisasm (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_SYSTEM_CONTEXT SystemContext
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
EFI_PHYSICAL_ADDRESS InstructionAddress;
UINTN InstructionNumber;
UINTN InstructionLength;
UINT8 Opcode;
CHAR16 *InstructionString;
// UINTN Result;
EFI_PHYSICAL_ADDRESS InstructionAddress;
UINTN InstructionNumber;
UINTN InstructionLength;
UINT8 Opcode;
CHAR16 *InstructionString;
// UINTN Result;
InstructionAddress = DebuggerPrivate->InstructionScope;
for (InstructionNumber = 0; InstructionNumber < DebuggerPrivate->InstructionNumber; InstructionNumber++) {
//
// Break each 0x10 instruction
//
if (((InstructionNumber % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
(InstructionNumber != 0)) {
(InstructionNumber != 0))
{
if (SetPageBreak ()) {
break;
}
}
Opcode = GET_OPCODE(InstructionAddress);
Opcode = GET_OPCODE (InstructionAddress);
if ((Opcode < OPCODE_MAX) && (mEdbDisasmInstructionTable[Opcode] != NULL)) {
InstructionLength = mEdbDisasmInstructionTable [Opcode] (InstructionAddress, SystemContext, &InstructionString);
InstructionLength = mEdbDisasmInstructionTable[Opcode](InstructionAddress, SystemContext, &InstructionString);
if (InstructionLength != 0) {
//
// Print Source
//
// Result = EdbPrintSource ((UINTN)InstructionAddress, FALSE);
// Result = EdbPrintSource ((UINTN)InstructionAddress, FALSE);
if (!DebuggerPrivate->DebuggerSymbolContext.DisplayCodeOnly) {
EdbPrintRaw (InstructionAddress, InstructionLength);
if (InstructionString != NULL) {
EDBPrint (L"%s\n", InstructionString);
@ -1182,30 +1186,31 @@ EdbShowDisasm (
**/
UINT64
GetRegisterValue (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN UINT8 Index
IN EFI_SYSTEM_CONTEXT SystemContext,
IN UINT8 Index
)
{
switch (Index) {
case 0:
return SystemContext.SystemContextEbc->R0;
case 1:
return SystemContext.SystemContextEbc->R1;
case 2:
return SystemContext.SystemContextEbc->R2;
case 3:
return SystemContext.SystemContextEbc->R3;
case 4:
return SystemContext.SystemContextEbc->R4;
case 5:
return SystemContext.SystemContextEbc->R5;
case 6:
return SystemContext.SystemContextEbc->R6;
case 7:
return SystemContext.SystemContextEbc->R7;
default:
ASSERT (FALSE);
break;
case 0:
return SystemContext.SystemContextEbc->R0;
case 1:
return SystemContext.SystemContextEbc->R1;
case 2:
return SystemContext.SystemContextEbc->R2;
case 3:
return SystemContext.SystemContextEbc->R3;
case 4:
return SystemContext.SystemContextEbc->R4;
case 5:
return SystemContext.SystemContextEbc->R5;
case 6:
return SystemContext.SystemContextEbc->R6;
case 7:
return SystemContext.SystemContextEbc->R7;
default:
ASSERT (FALSE);
break;
}
return 0;
}

View File

@ -11,16 +11,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Uefi.h>
#define EDB_BYTECODE_NUMBER_IN_LINE 5
#define EDB_BYTECODE_NUMBER_IN_LINE 5
#ifdef EFI32
#define EDB_PRINT_ADDRESS_FORMAT L"%08x: "
#define EDB_PRINT_ADDRESS_FORMAT L"%08x: "
#else
// To use 012l instead of 016l because space is not enough
#define EDB_PRINT_ADDRESS_FORMAT L"%012lx: "
#define EDB_PRINT_ADDRESS_FORMAT L"%012lx: "
#endif
#define OPCODE_MAX 0x40
#define OPCODE_MAX 0x40
#define EDB_INSTRUCTION_NAME_MAX_LENGTH 10
#define EDB_INSTRUCTION_NAME_MAX_SIZE (EDB_INSTRUCTION_NAME_MAX_LENGTH * sizeof(CHAR16))
@ -37,8 +37,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
EdbSetOffset (
IN UINTN InstructionNameOffset,
IN UINTN InstructionContentOffset
IN UINTN InstructionNameOffset,
IN UINTN InstructionContentOffset
);
/**
@ -76,7 +76,7 @@ EdbPostInstructionString (
**/
UINTN
EdbPrintInstructionName (
IN CHAR16 *Name
IN CHAR16 *Name
);
/**
@ -144,7 +144,7 @@ EdbGetNaturalIndex64 (
**/
UINTN
EdbPrintRawIndexData16 (
IN UINT16 Data16
IN UINT16 Data16
);
/**
@ -158,7 +158,7 @@ EdbPrintRawIndexData16 (
**/
UINTN
EdbPrintRawIndexData32 (
IN UINT32 Data32
IN UINT32 Data32
);
/**
@ -172,7 +172,7 @@ EdbPrintRawIndexData32 (
**/
UINTN
EdbPrintRawIndexData64 (
IN UINT64 Data64
IN UINT64 Data64
);
/**
@ -186,7 +186,7 @@ EdbPrintRawIndexData64 (
**/
UINTN
EdbPrintRegister1 (
IN UINT8 Operands
IN UINT8 Operands
);
/**
@ -200,7 +200,7 @@ EdbPrintRegister1 (
**/
UINTN
EdbPrintRegister2 (
IN UINT8 Operands
IN UINT8 Operands
);
/**
@ -214,7 +214,7 @@ EdbPrintRegister2 (
**/
UINTN
EdbPrintDedicatedRegister1 (
IN UINT8 Operands
IN UINT8 Operands
);
/**
@ -228,7 +228,7 @@ EdbPrintDedicatedRegister1 (
**/
UINTN
EdbPrintDedicatedRegister2 (
IN UINT8 Operands
IN UINT8 Operands
);
/**
@ -244,9 +244,9 @@ EdbPrintDedicatedRegister2 (
**/
UINTN
EdbPrintIndexData (
IN BOOLEAN Sign,
IN UINTN NaturalUnits,
IN UINTN ConstantUnits
IN BOOLEAN Sign,
IN UINTN NaturalUnits,
IN UINTN ConstantUnits
);
/**
@ -262,9 +262,9 @@ EdbPrintIndexData (
**/
UINTN
EdbPrintIndexData64 (
IN BOOLEAN Sign,
IN UINT64 NaturalUnits,
IN UINT64 ConstantUnits
IN BOOLEAN Sign,
IN UINT64 NaturalUnits,
IN UINT64 ConstantUnits
);
/**
@ -278,7 +278,7 @@ EdbPrintIndexData64 (
**/
UINTN
EdbPrintImmData8 (
IN UINT8 Data
IN UINT8 Data
);
/**
@ -292,7 +292,7 @@ EdbPrintImmData8 (
**/
UINTN
EdbPrintImmData16 (
IN UINT16 Data
IN UINT16 Data
);
/**
@ -306,7 +306,7 @@ EdbPrintImmData16 (
**/
UINTN
EdbPrintImmData32 (
IN UINT32 Data
IN UINT32 Data
);
/**
@ -320,7 +320,7 @@ EdbPrintImmData32 (
**/
UINTN
EdbPrintImmData64 (
IN UINT64 Data
IN UINT64 Data
);
/**
@ -334,7 +334,7 @@ EdbPrintImmData64 (
**/
UINTN
EdbPrintImmDatan (
IN UINTN Data
IN UINTN Data
);
/**
@ -348,7 +348,7 @@ EdbPrintImmDatan (
**/
UINTN
EdbPrintImmData64n (
IN UINT64 Data64
IN UINT64 Data64
);
/**
@ -362,7 +362,7 @@ EdbPrintImmData64n (
**/
UINTN
EdbPrintData8 (
IN UINT8 Data8
IN UINT8 Data8
);
/**
@ -376,7 +376,7 @@ EdbPrintData8 (
**/
UINTN
EdbPrintData16 (
IN UINT16 Data16
IN UINT16 Data16
);
/**
@ -390,7 +390,7 @@ EdbPrintData16 (
**/
UINTN
EdbPrintData32 (
IN UINT32 Data32
IN UINT32 Data32
);
/**
@ -404,7 +404,7 @@ EdbPrintData32 (
**/
UINTN
EdbPrintData64 (
IN UINT64 Data64
IN UINT64 Data64
);
/**
@ -418,7 +418,7 @@ EdbPrintData64 (
**/
UINTN
EdbPrintDatan (
IN UINTN Data
IN UINTN Data
);
/**
@ -432,7 +432,7 @@ EdbPrintDatan (
**/
UINTN
EdbPrintData64n (
IN UINT64 Data64
IN UINT64 Data64
);
/**
@ -446,7 +446,7 @@ EdbPrintData64n (
**/
UINTN
EdbPrintData8s (
IN UINT8 Data8
IN UINT8 Data8
);
/**
@ -460,7 +460,7 @@ EdbPrintData8s (
**/
UINTN
EdbPrintData16s (
IN UINT16 Data16
IN UINT16 Data16
);
/**
@ -474,7 +474,7 @@ EdbPrintData16s (
**/
UINTN
EdbPrintData32s (
IN UINT32 Data32
IN UINT32 Data32
);
/**
@ -488,7 +488,7 @@ EdbPrintData32s (
**/
UINTN
EdbPrintData64s (
IN UINT64 Data64
IN UINT64 Data64
);
/**
@ -515,7 +515,7 @@ EdbPrintComma (
**/
UINTN
EdbFindAndPrintSymbol (
IN UINTN Address
IN UINTN Address
);
/**
@ -528,8 +528,8 @@ EdbFindAndPrintSymbol (
**/
VOID
EdbPrintRaw (
IN EFI_PHYSICAL_ADDRESS InstructionAddress,
IN UINTN InstructionNumber
IN EFI_PHYSICAL_ADDRESS InstructionAddress,
IN UINTN InstructionNumber
);
/**
@ -544,8 +544,8 @@ EdbPrintRaw (
**/
EFI_STATUS
EdbShowDisasm (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_SYSTEM_CONTEXT SystemContext
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN EFI_SYSTEM_CONTEXT SystemContext
);
/**
@ -560,8 +560,8 @@ EdbShowDisasm (
**/
UINT64
GetRegisterValue (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN UINT8 Index
IN EFI_SYSTEM_CONTEXT SystemContext,
IN UINT8 Index
);
#endif

View File

@ -18,8 +18,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
EbcDebuggerCheckHookFlag (
IN VM_CONTEXT *VmPtr,
IN UINT32 Flag
IN VM_CONTEXT *VmPtr,
IN UINT32 Flag
)
{
if ((mDebuggerPrivate.FeatureFlags & Flag) == Flag) {
@ -30,7 +30,8 @@ EbcDebuggerCheckHookFlag (
VmPtr
);
}
return ;
return;
}
/**
@ -43,25 +44,26 @@ EbcDebuggerCheckHookFlag (
**/
VOID
EbcDebuggerPushCallstackSource (
IN UINT64 SourceEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
IN UINT64 SourceEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
)
{
if (mDebuggerPrivate.CallStackEntryCount > EFI_DEBUGGER_CALLSTACK_MAX) {
ASSERT (FALSE);
mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
}
//
// Record the new callstack entry
//
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].SourceAddress = SourceEntry;
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Type = Type;
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Type = Type;
//
// Do not change CallStackEntryCount
//
return ;
return;
}
/**
@ -74,14 +76,15 @@ EbcDebuggerPushCallstackSource (
**/
VOID
EbcDebuggerPushCallstackParameter (
IN UINT64 ParameterAddress,
IN EFI_DEBUGGER_BRANCH_TYPE Type
IN UINT64 ParameterAddress,
IN EFI_DEBUGGER_BRANCH_TYPE Type
)
{
if (mDebuggerPrivate.CallStackEntryCount > EFI_DEBUGGER_CALLSTACK_MAX) {
ASSERT (FALSE);
mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
}
//
// Record the new callstack parameter
//
@ -89,14 +92,14 @@ EbcDebuggerPushCallstackParameter (
CopyMem (
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Parameter,
(VOID *)(UINTN)ParameterAddress,
sizeof(mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Parameter)
sizeof (mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Parameter)
);
//
// Do not change CallStackEntryCount
//
return ;
return;
}
/**
@ -109,11 +112,11 @@ EbcDebuggerPushCallstackParameter (
**/
VOID
EbcDebuggerPushCallstackDest (
IN UINT64 DestEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
IN UINT64 DestEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
)
{
UINTN Index;
UINTN Index;
if (mDebuggerPrivate.CallStackEntryCount < EFI_DEBUGGER_CALLSTACK_MAX) {
//
@ -121,23 +124,25 @@ EbcDebuggerPushCallstackDest (
//
ASSERT (mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Type == Type);
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].DestAddress = DestEntry;
mDebuggerPrivate.CallStackEntryCount ++;
mDebuggerPrivate.CallStackEntryCount++;
} else {
//
// If there is no empty entry for callstack, throw the oldest one
//
ASSERT (mDebuggerPrivate.CallStackEntry[EFI_DEBUGGER_TRACE_MAX].Type == Type);
for (Index = 0; Index < EFI_DEBUGGER_CALLSTACK_MAX; Index++) {
CopyMem (&mDebuggerPrivate.CallStackEntry[Index],
&mDebuggerPrivate.CallStackEntry[Index + 1],
sizeof (mDebuggerPrivate.CallStackEntry[Index])
);
CopyMem (
&mDebuggerPrivate.CallStackEntry[Index],
&mDebuggerPrivate.CallStackEntry[Index + 1],
sizeof (mDebuggerPrivate.CallStackEntry[Index])
);
}
mDebuggerPrivate.CallStackEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry;
mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
}
return ;
return;
}
/**
@ -151,13 +156,14 @@ EbcDebuggerPopCallstack (
)
{
if ((mDebuggerPrivate.CallStackEntryCount > 0) &&
(mDebuggerPrivate.CallStackEntryCount <= EFI_DEBUGGER_CALLSTACK_MAX)) {
(mDebuggerPrivate.CallStackEntryCount <= EFI_DEBUGGER_CALLSTACK_MAX))
{
//
// Throw the newest one
//
mDebuggerPrivate.CallStackEntryCount --;
mDebuggerPrivate.CallStackEntryCount--;
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].SourceAddress = 0;
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].DestAddress = 0;
mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].DestAddress = 0;
} else if (mDebuggerPrivate.CallStackEntryCount == 0) {
//
// NOT assert here because it is reasonable, because when we start to build
@ -167,7 +173,7 @@ EbcDebuggerPopCallstack (
ASSERT (FALSE);
}
return ;
return;
}
/**
@ -180,25 +186,26 @@ EbcDebuggerPopCallstack (
**/
VOID
EbcDebuggerPushTraceSourceEntry (
IN UINT64 SourceEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
IN UINT64 SourceEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
)
{
if (mDebuggerPrivate.TraceEntryCount > EFI_DEBUGGER_TRACE_MAX) {
ASSERT (FALSE);
mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;
}
//
// Record the new trace entry
//
mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].SourceAddress = SourceEntry;
mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].Type = Type;
mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].Type = Type;
//
// Do not change TraceEntryCount
//
return ;
return;
}
/**
@ -211,11 +218,11 @@ EbcDebuggerPushTraceSourceEntry (
**/
VOID
EbcDebuggerPushTraceDestEntry (
IN UINT64 DestEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
IN UINT64 DestEntry,
IN EFI_DEBUGGER_BRANCH_TYPE Type
)
{
UINTN Index;
UINTN Index;
if (mDebuggerPrivate.TraceEntryCount < EFI_DEBUGGER_TRACE_MAX) {
//
@ -223,7 +230,7 @@ EbcDebuggerPushTraceDestEntry (
//
ASSERT (mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].Type == Type);
mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].DestAddress = DestEntry;
mDebuggerPrivate.TraceEntryCount ++;
mDebuggerPrivate.TraceEntryCount++;
} else {
//
// If there is no empty entry for trace, throw the oldest one
@ -236,11 +243,12 @@ EbcDebuggerPushTraceDestEntry (
sizeof (mDebuggerPrivate.TraceEntry[Index])
);
}
mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry;
mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;
mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;
}
return ;
return;
}
/**
@ -254,32 +262,34 @@ EbcDebuggerPushTraceDestEntry (
**/
VOID
EbcDebuggerPushStepEntry (
IN UINT64 Entry,
IN UINT64 FramePtr,
IN UINT32 Flag
IN UINT64 Entry,
IN UINT64 FramePtr,
IN UINT32 Flag
)
{
//
// Check StepOver
//
if ((Flag == EFI_DEBUG_FLAG_EBC_STEPOVER) &&
((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_STEPOVER) == EFI_DEBUG_FLAG_EBC_STEPOVER)) {
((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_STEPOVER) == EFI_DEBUG_FLAG_EBC_STEPOVER))
{
mDebuggerPrivate.StepContext.BreakAddress = Entry;
mDebuggerPrivate.StepContext.FramePointer = FramePtr;
mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOVER;
mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOVER;
}
//
// Check StepOut
//
if ((Flag == EFI_DEBUG_FLAG_EBC_STEPOUT) &&
((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_STEPOUT) == EFI_DEBUG_FLAG_EBC_STEPOUT)) {
((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_STEPOUT) == EFI_DEBUG_FLAG_EBC_STEPOUT))
{
mDebuggerPrivate.StepContext.BreakAddress = Entry;
mDebuggerPrivate.StepContext.FramePointer = FramePtr;
mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOUT;
mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOUT;
}
}
/**
Notify the callback function when an event is triggered.
@ -290,14 +300,14 @@ EbcDebuggerPushStepEntry (
VOID
EFIAPI
EbcDebuggerBreakEventFunc (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
if ((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_BOK) != EFI_DEBUG_FLAG_EBC_BOK) {
return ;
return;
}
Status = gBS->CheckEvent (gST->ConIn->WaitForKey);
@ -321,44 +331,43 @@ EbcDebuggerHookInit (
IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol
)
{
EFI_STATUS Status;
UINTN Index;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
EFI_STATUS Status;
UINTN Index;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
//
// Register all exception handler
//
for (Index = EXCEPT_EBC_UNDEFINED; Index <= EXCEPT_EBC_STEP; Index++) {
EbcDebugProtocol->RegisterExceptionCallback (
EbcDebugProtocol,
0,
NULL,
Index
);
EbcDebugProtocol,
0,
NULL,
Index
);
EbcDebugProtocol->RegisterExceptionCallback (
EbcDebugProtocol,
0,
EdbExceptionHandler,
Index
);
EbcDebugProtocol,
0,
EdbExceptionHandler,
Index
);
}
//
// Init Symbol
//
Object = AllocateZeroPool (sizeof(EFI_DEBUGGER_SYMBOL_OBJECT) * EFI_DEBUGGER_SYMBOL_OBJECT_MAX);
Object = AllocateZeroPool (sizeof (EFI_DEBUGGER_SYMBOL_OBJECT) * EFI_DEBUGGER_SYMBOL_OBJECT_MAX);
ASSERT (Object != NULL);
mDebuggerPrivate.DebuggerSymbolContext.Object = Object;
mDebuggerPrivate.DebuggerSymbolContext.ObjectCount = 0;
mDebuggerPrivate.DebuggerSymbolContext.Object = Object;
mDebuggerPrivate.DebuggerSymbolContext.ObjectCount = 0;
mDebuggerPrivate.DebuggerSymbolContext.MaxObjectCount = EFI_DEBUGGER_SYMBOL_OBJECT_MAX;
for (Index = 0; Index < EFI_DEBUGGER_SYMBOL_OBJECT_MAX; Index++) {
Entry = AllocateZeroPool (sizeof(EFI_DEBUGGER_SYMBOL_ENTRY) * EFI_DEBUGGER_SYMBOL_ENTRY_MAX);
Entry = AllocateZeroPool (sizeof (EFI_DEBUGGER_SYMBOL_ENTRY) * EFI_DEBUGGER_SYMBOL_ENTRY_MAX);
ASSERT (Entry != NULL);
Object[Index].Entry = Entry;
Object[Index].Entry = Entry;
Object[Index].MaxEntryCount = EFI_DEBUGGER_SYMBOL_ENTRY_MAX;
Object[Index].SourceBuffer = AllocateZeroPool (sizeof(VOID *) * (EFI_DEBUGGER_SYMBOL_ENTRY_MAX + 1));
Object[Index].SourceBuffer = AllocateZeroPool (sizeof (VOID *) * (EFI_DEBUGGER_SYMBOL_ENTRY_MAX + 1));
ASSERT (Object[Index].SourceBuffer != NULL);
}
@ -368,7 +377,7 @@ EbcDebuggerHookInit (
Status = gBS->LocateProtocol (
&gEfiPciRootBridgeIoProtocolGuid,
NULL,
(VOID**) &mDebuggerPrivate.PciRootBridgeIo
(VOID **)&mDebuggerPrivate.PciRootBridgeIo
);
//
@ -376,7 +385,7 @@ EbcDebuggerHookInit (
//
Status = EfiGetSystemConfigurationTable (
&gEfiDebugImageInfoTableGuid,
(VOID**) &mDebuggerPrivate.DebugImageInfoTableHeader
(VOID **)&mDebuggerPrivate.DebugImageInfoTableHeader
);
//
@ -408,7 +417,7 @@ EbcDebuggerHookInit (
);
}
return ;
return;
}
/**
@ -422,9 +431,9 @@ EbcDebuggerHookUnload (
VOID
)
{
UINTN Index;
UINTN SubIndex;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
UINTN Index;
UINTN SubIndex;
EFI_DEBUGGER_SYMBOL_OBJECT *Object;
//
// Close the break event
@ -442,7 +451,7 @@ EbcDebuggerHookUnload (
// Clean up Entry
//
gBS->FreePool (Object[Index].Entry);
Object[Index].Entry = NULL;
Object[Index].Entry = NULL;
Object[Index].EntryCount = 0;
//
// Clean up source buffer
@ -451,6 +460,7 @@ EbcDebuggerHookUnload (
gBS->FreePool (Object[Index].SourceBuffer[SubIndex]);
Object[Index].SourceBuffer[SubIndex] = NULL;
}
gBS->FreePool (Object[Index].SourceBuffer);
Object[Index].SourceBuffer = NULL;
}
@ -459,13 +469,13 @@ EbcDebuggerHookUnload (
// Clean up Object
//
gBS->FreePool (Object);
mDebuggerPrivate.DebuggerSymbolContext.Object = NULL;
mDebuggerPrivate.DebuggerSymbolContext.Object = NULL;
mDebuggerPrivate.DebuggerSymbolContext.ObjectCount = 0;
//
// Done
//
return ;
return;
}
/**
@ -478,10 +488,10 @@ EbcDebuggerHookUnload (
**/
VOID
EbcDebuggerHookEbcUnloadImage (
IN EFI_HANDLE Handle
IN EFI_HANDLE Handle
)
{
return ;
return;
}
/**
@ -496,14 +506,14 @@ EbcDebuggerHookEbcUnloadImage (
**/
VOID
EbcDebuggerHookExecuteEbcImageEntryPoint (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushCallstackSource ((UINT64)(UINTN)-1, EfiDebuggerBranchTypeEbcCall);
EbcDebuggerPushCallstackParameter ((UINT64)(UINTN)VmPtr->Gpr[0], EfiDebuggerBranchTypeEbcCall);
EbcDebuggerPushCallstackDest ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCall);
EbcDebuggerCheckHookFlag (VmPtr, EFI_DEBUG_FLAG_EBC_BOE);
return ;
return;
}
/**
@ -517,14 +527,14 @@ EbcDebuggerHookExecuteEbcImageEntryPoint (
**/
VOID
EbcDebuggerHookEbcInterpret (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushCallstackSource ((UINT64)(UINTN)-2, EfiDebuggerBranchTypeEbcCall);
EbcDebuggerPushCallstackParameter ((UINT64)(UINTN)VmPtr->Gpr[0], EfiDebuggerBranchTypeEbcCall);
EbcDebuggerPushCallstackDest ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCall);
EbcDebuggerCheckHookFlag (VmPtr, EFI_DEBUG_FLAG_EBC_BOT);
return ;
return;
}
/**
@ -537,16 +547,16 @@ EbcDebuggerHookEbcInterpret (
**/
VOID
EbcDebuggerHookExecuteStart (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EFI_TPL CurrentTpl;
EFI_TPL CurrentTpl;
//
// Check Ip for GoTil
//
if (mDebuggerPrivate.GoTilContext.BreakAddress == (UINT64)(UINTN)VmPtr->Ip) {
mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_GT;
mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_GT;
mDebuggerPrivate.GoTilContext.BreakAddress = 0;
EbcDebugSignalException (
EXCEPT_EBC_BREAKPOINT,
@ -554,14 +564,16 @@ EbcDebuggerHookExecuteStart (
VmPtr
);
mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_GT;
return ;
return;
}
//
// Check ReturnAddress for StepOver
//
if ((mDebuggerPrivate.StepContext.BreakAddress == (UINT64)(UINTN)VmPtr->Ip) &&
(mDebuggerPrivate.StepContext.FramePointer == (UINT64)(UINTN)VmPtr->FramePtr)) {
mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_STEPOVER;
(mDebuggerPrivate.StepContext.FramePointer == (UINT64)(UINTN)VmPtr->FramePtr))
{
mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_STEPOVER;
mDebuggerPrivate.StepContext.BreakAddress = 0;
mDebuggerPrivate.StepContext.FramePointer = 0;
EbcDebugSignalException (
@ -571,11 +583,12 @@ EbcDebuggerHookExecuteStart (
);
mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOVER;
}
//
// Check FramePtr for StepOut
//
if (mDebuggerPrivate.StepContext.BreakAddress == (UINT64)(UINTN)VmPtr->FramePtr) {
mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_STEPOUT;
mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_STEPOUT;
mDebuggerPrivate.StepContext.BreakAddress = 0;
mDebuggerPrivate.StepContext.FramePointer = 0;
EbcDebugSignalException (
@ -585,6 +598,7 @@ EbcDebuggerHookExecuteStart (
);
mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOUT;
}
//
// Check Flags for BreakOnKey
//
@ -603,7 +617,8 @@ EbcDebuggerHookExecuteStart (
mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOK;
}
}
return ;
return;
}
/**
@ -616,7 +631,7 @@ EbcDebuggerHookExecuteStart (
**/
VOID
EbcDebuggerHookExecuteEnd (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
UINTN Address;
@ -624,10 +639,10 @@ EbcDebuggerHookExecuteEnd (
//
// Use FramePtr as checkpoint for StepOut
//
CopyMem (&Address, (VOID *)((UINTN)VmPtr->FramePtr), sizeof(Address));
CopyMem (&Address, (VOID *)((UINTN)VmPtr->FramePtr), sizeof (Address));
EbcDebuggerPushStepEntry (Address, (UINT64)(UINTN)VmPtr->FramePtr, EFI_DEBUG_FLAG_EBC_STEPOUT);
return ;
return;
}
/**
@ -641,14 +656,14 @@ EbcDebuggerHookExecuteEnd (
**/
VOID
EbcDebuggerHookCALLStart (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerCheckHookFlag (VmPtr, EFI_DEBUG_FLAG_EBC_BOC);
EbcDebuggerPushCallstackSource ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCall);
EbcDebuggerPushCallstackParameter ((UINT64)(UINTN)VmPtr->Gpr[0], EfiDebuggerBranchTypeEbcCall);
EbcDebuggerPushTraceSourceEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCall);
return ;
return;
}
/**
@ -662,7 +677,7 @@ EbcDebuggerHookCALLStart (
**/
VOID
EbcDebuggerHookCALLEnd (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
UINT64 Address;
@ -674,22 +689,22 @@ EbcDebuggerHookCALLEnd (
//
// Get Old FramePtr
//
CopyMem (&FramePtr, (VOID *)((UINTN)VmPtr->FramePtr), sizeof(FramePtr));
CopyMem (&FramePtr, (VOID *)((UINTN)VmPtr->FramePtr), sizeof (FramePtr));
//
// Use ReturnAddress as checkpoint for StepOver
//
CopyMem (&Address, (VOID *)(UINTN)VmPtr->Gpr[0], sizeof(Address));
CopyMem (&Address, (VOID *)(UINTN)VmPtr->Gpr[0], sizeof (Address));
EbcDebuggerPushStepEntry (Address, FramePtr, EFI_DEBUG_FLAG_EBC_STEPOVER);
//
// Use FramePtr as checkpoint for StepOut
//
Address = 0;
CopyMem (&Address, (VOID *)(FramePtr), sizeof(UINTN));
CopyMem (&Address, (VOID *)(FramePtr), sizeof (UINTN));
EbcDebuggerPushStepEntry (Address, FramePtr, EFI_DEBUG_FLAG_EBC_STEPOUT);
return ;
return;
}
/**
@ -703,14 +718,14 @@ EbcDebuggerHookCALLEnd (
**/
VOID
EbcDebuggerHookCALLEXStart (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerCheckHookFlag (VmPtr, EFI_DEBUG_FLAG_EBC_BOCX);
// EbcDebuggerPushCallstackSource ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCallEx);
// EbcDebuggerPushCallstackParameter ((UINT64)(UINTN)VmPtr->R[0], EfiDebuggerBranchTypeEbcCallEx);
// EbcDebuggerPushCallstackSource ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCallEx);
// EbcDebuggerPushCallstackParameter ((UINT64)(UINTN)VmPtr->R[0], EfiDebuggerBranchTypeEbcCallEx);
EbcDebuggerPushTraceSourceEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCallEx);
return ;
return;
}
/**
@ -723,12 +738,12 @@ EbcDebuggerHookCALLEXStart (
**/
VOID
EbcDebuggerHookCALLEXEnd (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
// EbcDebuggerPushCallstackDest ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCallEx);
// EbcDebuggerPushCallstackDest ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCallEx);
EbcDebuggerPushTraceDestEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcCallEx);
return ;
return;
}
/**
@ -742,13 +757,13 @@ EbcDebuggerHookCALLEXEnd (
**/
VOID
EbcDebuggerHookRETStart (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerCheckHookFlag (VmPtr, EFI_DEBUG_FLAG_EBC_BOR);
EbcDebuggerPopCallstack ();
EbcDebuggerPushTraceSourceEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcRet);
return ;
return;
}
/**
@ -761,11 +776,11 @@ EbcDebuggerHookRETStart (
**/
VOID
EbcDebuggerHookRETEnd (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushTraceDestEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcRet);
return ;
return;
}
/**
@ -778,11 +793,11 @@ EbcDebuggerHookRETEnd (
**/
VOID
EbcDebuggerHookJMPStart (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushTraceSourceEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcJmp);
return ;
return;
}
/**
@ -795,11 +810,11 @@ EbcDebuggerHookJMPStart (
**/
VOID
EbcDebuggerHookJMPEnd (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushTraceDestEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcJmp);
return ;
return;
}
/**
@ -812,11 +827,11 @@ EbcDebuggerHookJMPEnd (
**/
VOID
EbcDebuggerHookJMP8Start (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushTraceSourceEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcJmp8);
return ;
return;
}
/**
@ -829,9 +844,9 @@ EbcDebuggerHookJMP8Start (
**/
VOID
EbcDebuggerHookJMP8End (
IN VM_CONTEXT *VmPtr
IN VM_CONTEXT *VmPtr
)
{
EbcDebuggerPushTraceDestEntry ((UINT64)(UINTN)VmPtr->Ip, EfiDebuggerBranchTypeEbcJmp8);
return ;
return;
}

View File

@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_DEBUGGER_LINE_NUMBER_IN_PAGE 0x10
#define EFI_DEBUG_MAX_PRINT_BUFFER (80 * 4)
#define EFI_DEBUG_MAX_PRINT_BUFFER (80 * 4)
/**
@ -99,8 +99,8 @@ AsciiAtoi (
INTN
EFIAPI
StrCmpUnicodeAndAscii (
IN CHAR16 *String,
IN CHAR8 *String2
IN CHAR16 *String,
IN CHAR8 *String2
);
/**
@ -118,8 +118,8 @@ StrCmpUnicodeAndAscii (
INTN
EFIAPI
StriCmp (
IN CHAR16 *String,
IN CHAR16 *String2
IN CHAR16 *String,
IN CHAR16 *String2
);
/**
@ -137,8 +137,8 @@ StriCmp (
INTN
EFIAPI
StriCmpUnicodeAndAscii (
IN CHAR16 *String,
IN CHAR8 *String2
IN CHAR16 *String,
IN CHAR8 *String2
);
/**
@ -152,8 +152,8 @@ StriCmpUnicodeAndAscii (
BOOLEAN
EFIAPI
StrEndWith (
IN CHAR16 *Str,
IN CHAR16 *SubStr
IN CHAR16 *Str,
IN CHAR16 *SubStr
);
/**
@ -165,7 +165,7 @@ StrEndWith (
CHAR16 *
EFIAPI
StrDuplicate (
IN CHAR16 *Src
IN CHAR16 *Src
);
/**
@ -179,8 +179,8 @@ StrDuplicate (
CHAR16 *
EFIAPI
StrGetNewTokenLine (
IN CHAR16 *String,
IN CHAR16 *CharSet
IN CHAR16 *String,
IN CHAR16 *CharSet
);
/**
@ -193,7 +193,7 @@ StrGetNewTokenLine (
CHAR16 *
EFIAPI
StrGetNextTokenLine (
IN CHAR16 *CharSet
IN CHAR16 *CharSet
);
/**
@ -207,8 +207,8 @@ StrGetNextTokenLine (
CHAR16 *
EFIAPI
StrGetNewTokenField (
IN CHAR16 *String,
IN CHAR16 *CharSet
IN CHAR16 *String,
IN CHAR16 *CharSet
);
/**
@ -221,7 +221,7 @@ StrGetNewTokenField (
CHAR16 *
EFIAPI
StrGetNextTokenField (
IN CHAR16 *CharSet
IN CHAR16 *CharSet
);
/**
@ -235,8 +235,8 @@ StrGetNextTokenField (
VOID
EFIAPI
PatchForStrTokenAfter (
IN CHAR16 *Buffer,
IN CHAR16 Patch
IN CHAR16 *Buffer,
IN CHAR16 Patch
);
/**
@ -249,8 +249,8 @@ PatchForStrTokenAfter (
VOID
EFIAPI
PatchForStrTokenBefore (
IN CHAR16 *Buffer,
IN CHAR16 Patch
IN CHAR16 *Buffer,
IN CHAR16 Patch
);
/**
@ -264,8 +264,8 @@ PatchForStrTokenBefore (
CHAR8 *
EFIAPI
AsciiStrGetNewTokenLine (
IN CHAR8 *String,
IN CHAR8 *CharSet
IN CHAR8 *String,
IN CHAR8 *CharSet
);
/**
@ -278,7 +278,7 @@ AsciiStrGetNewTokenLine (
CHAR8 *
EFIAPI
AsciiStrGetNextTokenLine (
IN CHAR8 *CharSet
IN CHAR8 *CharSet
);
/**
@ -292,8 +292,8 @@ AsciiStrGetNextTokenLine (
CHAR8 *
EFIAPI
AsciiStrGetNewTokenField (
IN CHAR8 *String,
IN CHAR8 *CharSet
IN CHAR8 *String,
IN CHAR8 *CharSet
);
/**
@ -306,7 +306,7 @@ AsciiStrGetNewTokenField (
CHAR8 *
EFIAPI
AsciiStrGetNextTokenField (
IN CHAR8 *CharSet
IN CHAR8 *CharSet
);
/**
@ -320,8 +320,8 @@ AsciiStrGetNextTokenField (
VOID
EFIAPI
PatchForAsciiStrTokenAfter (
IN CHAR8 *Buffer,
IN CHAR8 Patch
IN CHAR8 *Buffer,
IN CHAR8 Patch
);
/**
@ -334,8 +334,8 @@ PatchForAsciiStrTokenAfter (
VOID
EFIAPI
PatchForAsciiStrTokenBefore (
IN CHAR8 *Buffer,
IN CHAR8 Patch
IN CHAR8 *Buffer,
IN CHAR8 Patch
);
/**
@ -351,9 +351,9 @@ PatchForAsciiStrTokenBefore (
VOID
EFIAPI
Input (
IN CHAR16 *Prompt OPTIONAL,
OUT CHAR16 *InStr,
IN UINTN StrLen
IN CHAR16 *Prompt OPTIONAL,
OUT CHAR16 *InStr,
IN UINTN StrLen
);
/**
@ -446,11 +446,11 @@ EDBSPrintWithOffset (
EFI_STATUS
EFIAPI
ReadFileToBuffer (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
OUT UINTN *BufferSize,
OUT VOID **Buffer,
IN BOOLEAN ScanFs
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
OUT UINTN *BufferSize,
OUT VOID **Buffer,
IN BOOLEAN ScanFs
);
/**
@ -468,10 +468,10 @@ ReadFileToBuffer (
CHAR16 *
EFIAPI
GetFileNameUnderDir (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *DirName,
IN CHAR16 *FileName,
IN OUT UINTN *Index
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *DirName,
IN CHAR16 *FileName,
IN OUT UINTN *Index
);
#endif

View File

@ -23,19 +23,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
ReadFileFromVol (
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol,
IN CHAR16 *FileName,
OUT UINTN *BufferSize,
OUT VOID **Buffer
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol,
IN CHAR16 *FileName,
OUT UINTN *BufferSize,
OUT VOID **Buffer
)
{
EFI_STATUS Status;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
UINTN FileInfoSize;
EFI_FILE_INFO *FileInfo;
UINTN TempBufferSize;
VOID *TempBuffer;
EFI_STATUS Status;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
UINTN FileInfoSize;
EFI_FILE_INFO *FileInfo;
UINTN TempBufferSize;
VOID *TempBuffer;
//
// Open the root directory
@ -65,7 +65,7 @@ ReadFileFromVol (
//
// Get the file information
//
FileInfoSize = sizeof(EFI_FILE_INFO) + 1024;
FileInfoSize = sizeof (EFI_FILE_INFO) + 1024;
FileInfo = AllocateZeroPool (FileInfoSize);
if (FileInfo == NULL) {
@ -88,8 +88,8 @@ ReadFileFromVol (
//
// Allocate buffer for the file data. The last CHAR16 is for L'\0'
//
TempBufferSize = (UINTN) FileInfo->FileSize + sizeof(CHAR16);
TempBuffer = AllocateZeroPool (TempBufferSize);
TempBufferSize = (UINTN)FileInfo->FileSize + sizeof (CHAR16);
TempBuffer = AllocateZeroPool (TempBufferSize);
if (TempBuffer == NULL) {
Handle->Close (Handle);
gBS->FreePool (FileInfo);
@ -141,20 +141,20 @@ ReadFileFromVol (
EFI_STATUS
EFIAPI
ReadFileToBuffer (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
OUT UINTN *BufferSize,
OUT VOID **Buffer,
IN BOOLEAN ScanFs
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
OUT UINTN *BufferSize,
OUT VOID **Buffer,
IN BOOLEAN ScanFs
)
{
EFI_STATUS Status;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
UINTN TempBufferSize;
VOID *TempBuffer;
UINTN NoHandles;
EFI_HANDLE *HandleBuffer;
UINTN Index;
EFI_STATUS Status;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
UINTN TempBufferSize;
VOID *TempBuffer;
UINTN NoHandles;
EFI_HANDLE *HandleBuffer;
UINTN Index;
//
// Check parameters
@ -170,6 +170,7 @@ ReadFileToBuffer (
if (DebuggerPrivate->Vol == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Read file directly from Vol
//
@ -184,12 +185,12 @@ ReadFileToBuffer (
// Get all Vol handle
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
NULL,
&NoHandles,
&HandleBuffer
);
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
NULL,
&NoHandles,
&HandleBuffer
);
if (EFI_ERROR (Status) && (NoHandles == 0)) {
return EFI_NOT_FOUND;
}
@ -198,15 +199,15 @@ ReadFileToBuffer (
// Walk through each Vol
//
DebuggerPrivate->Vol = NULL;
*BufferSize = 0;
*Buffer = NULL;
*BufferSize = 0;
*Buffer = NULL;
for (Index = 0; Index < NoHandles; Index++) {
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiSimpleFileSystemProtocolGuid,
(VOID**) &Vol
(VOID **)&Vol
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
continue;
}
@ -228,8 +229,8 @@ ReadFileToBuffer (
// Record value
//
DebuggerPrivate->Vol = Vol;
*BufferSize = TempBufferSize;
*Buffer = TempBuffer;
*BufferSize = TempBufferSize;
*Buffer = TempBuffer;
}
}
}
@ -262,31 +263,32 @@ ReadFileToBuffer (
CHAR16 *
EFIAPI
GetFileNameUnderDir (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *DirName,
IN CHAR16 *FileName,
IN OUT UINTN *Index
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *DirName,
IN CHAR16 *FileName,
IN OUT UINTN *Index
)
{
EFI_STATUS Status;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
UINTN FileInfoSize;
EFI_FILE_INFO *FileInfo;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
VOID *TempName;
UINTN FileIndex;
EFI_STATUS Status;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
UINTN FileInfoSize;
EFI_FILE_INFO *FileInfo;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
VOID *TempName;
UINTN FileIndex;
if (DebuggerPrivate->Vol == NULL) {
Status = gBS->LocateProtocol (
&gEfiSimpleFileSystemProtocolGuid,
NULL,
(VOID**) &DebuggerPrivate->Vol
(VOID **)&DebuggerPrivate->Vol
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return NULL;
}
}
Vol = DebuggerPrivate->Vol;
//
@ -311,6 +313,7 @@ GetFileNameUnderDir (
RootDir->Close (RootDir);
return NULL;
}
RootDir->Close (RootDir);
//
@ -325,7 +328,7 @@ GetFileNameUnderDir (
//
// Get the file information
//
FileInfoSize = sizeof(EFI_FILE_INFO) + 1024;
FileInfoSize = sizeof (EFI_FILE_INFO) + 1024;
FileInfo = AllocateZeroPool (FileInfoSize);
if (FileInfo == NULL) {
@ -337,12 +340,12 @@ GetFileNameUnderDir (
// Walk through each file in the directory
//
FileIndex = 0;
TempName = NULL;
TempName = NULL;
while (TRUE) {
//
// Read a file entry
//
FileInfoSize = sizeof(EFI_FILE_INFO) + 1024;
FileInfoSize = sizeof (EFI_FILE_INFO) + 1024;
Status = Handle->Read (
Handle,
@ -367,10 +370,11 @@ GetFileNameUnderDir (
if (FileIndex == *Index) {
TempName = StrDuplicate (FileInfo->FileName);
*Index = *Index + 1;
*Index = *Index + 1;
break;
}
FileIndex ++;
FileIndex++;
}
}

View File

@ -27,38 +27,41 @@ Xtoi (
ASSERT (Str != NULL);
MaxVal = (UINTN) -1 >> 4;
MaxVal = (UINTN)-1 >> 4;
//
// skip preceeding white space
//
while (*Str != '\0' && *Str == ' ') {
Str += 1;
}
//
// skip preceeding zeros
//
while (*Str != '\0' && *Str == '0') {
Str += 1;
}
//
// skip preceeding white space
//
if (*Str != '\0' && (*Str == 'x' || *Str == 'X')) {
if ((*Str != '\0') && ((*Str == 'x') || (*Str == 'X'))) {
Str += 1;
}
//
// convert hex digits
//
RetVal = 0;
RetVal = 0;
TempChar = *(Str++);
while (TempChar != '\0') {
if (TempChar >= 'a' && TempChar <= 'f') {
if ((TempChar >= 'a') && (TempChar <= 'f')) {
TempChar -= 'a' - 'A';
}
if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {
if (((TempChar >= '0') && (TempChar <= '9')) || ((TempChar >= 'A') && (TempChar <= 'F'))) {
if (RetVal > MaxVal) {
return (UINTN) -1;
return (UINTN)-1;
}
RetVal = (RetVal << 4) | (TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'));
@ -91,38 +94,41 @@ LXtoi (
ASSERT (Str != NULL);
MaxVal = RShiftU64 ((UINT64) -1, 4);
MaxVal = RShiftU64 ((UINT64)-1, 4);
//
// skip preceeding white space
//
while (*Str != '\0' && *Str == ' ') {
Str += 1;
}
//
// skip preceeding zeros
//
while (*Str != '\0' && *Str == '0') {
Str += 1;
}
//
// skip preceeding white space
//
if (*Str != '\0' && (*Str == 'x' || *Str == 'X')) {
if ((*Str != '\0') && ((*Str == 'x') || (*Str == 'X'))) {
Str += 1;
}
//
// convert hex digits
//
RetVal = 0;
RetVal = 0;
TempChar = *(Str++);
while (TempChar != '\0') {
if (TempChar >= 'a' && TempChar <= 'f') {
if ((TempChar >= 'a') && (TempChar <= 'f')) {
TempChar -= 'a' - 'A';
}
if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {
if (((TempChar >= '0') && (TempChar <= '9')) || ((TempChar >= 'A') && (TempChar <= 'F'))) {
if (RetVal > MaxVal) {
return (UINT64) -1;
return (UINT64)-1;
}
RetVal = LShiftU64 (RetVal, 4);
@ -157,23 +163,24 @@ Atoi (
ASSERT (Str != NULL);
MaxVal = (UINTN) -1 / 10;
ResteVal = (UINTN) -1 % 10;
MaxVal = (UINTN)-1 / 10;
ResteVal = (UINTN)-1 % 10;
//
// skip preceeding white space
//
while (*Str != '\0' && *Str == ' ') {
Str += 1;
}
//
// convert digits
//
RetVal = 0;
RetVal = 0;
TempChar = *(Str++);
while (TempChar != '\0') {
if (TempChar >= '0' && TempChar <= '9') {
if (RetVal > MaxVal || (RetVal == MaxVal && TempChar - '0' > (INTN) ResteVal)) {
return (UINTN) -1;
if ((TempChar >= '0') && (TempChar <= '9')) {
if ((RetVal > MaxVal) || ((RetVal == MaxVal) && (TempChar - '0' > (INTN)ResteVal))) {
return (UINTN)-1;
}
RetVal = (RetVal * 10) + TempChar - '0';
@ -200,44 +207,47 @@ AsciiXtoi (
CHAR8 *Str
)
{
UINTN RetVal;
CHAR8 TempChar;
UINTN MaxVal;
UINTN RetVal;
CHAR8 TempChar;
UINTN MaxVal;
ASSERT (Str != NULL);
MaxVal = (UINTN) -1 >> 4;
MaxVal = (UINTN)-1 >> 4;
//
// skip preceeding white space
//
while (*Str != '\0' && *Str == ' ') {
Str += 1;
}
//
// skip preceeding zeros
//
while (*Str != '\0' && *Str == '0') {
Str += 1;
}
//
// skip preceeding white space
//
if (*Str != '\0' && (*Str == 'x' || *Str == 'X')) {
if ((*Str != '\0') && ((*Str == 'x') || (*Str == 'X'))) {
Str += 1;
}
//
// convert hex digits
//
RetVal = 0;
RetVal = 0;
TempChar = *(Str++);
while (TempChar != '\0') {
if (TempChar >= 'a' && TempChar <= 'f') {
if ((TempChar >= 'a') && (TempChar <= 'f')) {
TempChar -= 'a' - 'A';
}
if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {
if (((TempChar >= '0') && (TempChar <= '9')) || ((TempChar >= 'A') && (TempChar <= 'F'))) {
if (RetVal > MaxVal) {
return (UINTN) -1;
return (UINTN)-1;
}
RetVal = (RetVal << 4) | (TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'));
@ -264,30 +274,31 @@ AsciiAtoi (
CHAR8 *Str
)
{
UINTN RetVal;
CHAR8 TempChar;
UINTN MaxVal;
UINTN ResteVal;
UINTN RetVal;
CHAR8 TempChar;
UINTN MaxVal;
UINTN ResteVal;
ASSERT (Str != NULL);
MaxVal = (UINTN) -1 / 10;
ResteVal = (UINTN) -1 % 10;
MaxVal = (UINTN)-1 / 10;
ResteVal = (UINTN)-1 % 10;
//
// skip preceeding white space
//
while (*Str != '\0' && *Str == ' ') {
Str += 1;
}
//
// convert digits
//
RetVal = 0;
RetVal = 0;
TempChar = *(Str++);
while (TempChar != '\0') {
if (TempChar >= '0' && TempChar <= '9') {
if (RetVal > MaxVal || (RetVal == MaxVal && TempChar - '0' > (INTN) ResteVal)) {
return (UINTN) -1;
if ((TempChar >= '0') && (TempChar <= '9')) {
if ((RetVal > MaxVal) || ((RetVal == MaxVal) && (TempChar - '0' > (INTN)ResteVal))) {
return (UINTN)-1;
}
RetVal = (RetVal * 10) + TempChar - '0';
@ -301,7 +312,6 @@ AsciiAtoi (
return RetVal;
}
/**
Compare the Unicode and Ascii string pointed by String to the string pointed by String2.
@ -317,8 +327,8 @@ AsciiAtoi (
INTN
EFIAPI
StrCmpUnicodeAndAscii (
IN CHAR16 *String,
IN CHAR8 *String2
IN CHAR16 *String,
IN CHAR8 *String2
)
{
while (*String != '\0') {
@ -326,7 +336,7 @@ StrCmpUnicodeAndAscii (
break;
}
String += 1;
String += 1;
String2 += 1;
}
@ -348,12 +358,13 @@ StrCmpUnicodeAndAscii (
INTN
EFIAPI
StriCmp (
IN CHAR16 *String,
IN CHAR16 *String2
IN CHAR16 *String,
IN CHAR16 *String2
)
{
while ((*String != L'\0') &&
(CharToUpper (*String) == CharToUpper (*String2))) {
(CharToUpper (*String) == CharToUpper (*String2)))
{
String++;
String2++;
}
@ -376,12 +387,13 @@ StriCmp (
INTN
EFIAPI
StriCmpUnicodeAndAscii (
IN CHAR16 *String,
IN CHAR8 *String2
IN CHAR16 *String,
IN CHAR8 *String2
)
{
while ((*String != L'\0') &&
(CharToUpper (*String) == (CHAR16)AsciiCharToUpper (*String2))) {
(CharToUpper (*String) == (CHAR16)AsciiCharToUpper (*String2)))
{
String++;
String2++;
}
@ -400,17 +412,17 @@ StriCmpUnicodeAndAscii (
BOOLEAN
EFIAPI
StrEndWith (
IN CHAR16 *Str,
IN CHAR16 *SubStr
IN CHAR16 *Str,
IN CHAR16 *SubStr
)
{
CHAR16 *Temp;
if ((Str == NULL) || (SubStr == NULL) || (StrLen(Str) < StrLen(SubStr))) {
if ((Str == NULL) || (SubStr == NULL) || (StrLen (Str) < StrLen (SubStr))) {
return FALSE;
}
Temp = Str + StrLen(Str) - StrLen(SubStr);
Temp = Str + StrLen (Str) - StrLen (SubStr);
//
// Compare
@ -431,23 +443,23 @@ StrEndWith (
CHAR16 *
EFIAPI
StrDuplicate (
IN CHAR16 *Src
IN CHAR16 *Src
)
{
CHAR16 *Dest;
UINTN Size;
CHAR16 *Dest;
UINTN Size;
Size = (StrLen(Src) + 1) * sizeof(CHAR16);
Size = (StrLen (Src) + 1) * sizeof (CHAR16);
Dest = AllocateZeroPool (Size);
if (Dest != NULL) {
CopyMem (Dest, Src, Size);
}
return Dest;
}
CHAR16 *mLineBuffer = NULL;
CHAR16 *mFieldBuffer = NULL;
CHAR16 *mLineBuffer = NULL;
CHAR16 *mFieldBuffer = NULL;
/**
@ -460,8 +472,8 @@ CHAR16 *mFieldBuffer = NULL;
UINTN
EFIAPI
StrSpn (
IN CHAR16 *String,
IN CHAR16 *CharSet
IN CHAR16 *String,
IN CHAR16 *CharSet
)
{
UINTN Count;
@ -470,8 +482,8 @@ StrSpn (
Count = 0;
for (Str1 = String; *Str1 != L'\0'; Str1 ++) {
for (Str2 = CharSet; *Str2 != L'\0'; Str2 ++) {
for (Str1 = String; *Str1 != L'\0'; Str1++) {
for (Str2 = CharSet; *Str2 != L'\0'; Str2++) {
if (*Str1 == *Str2) {
break;
}
@ -481,7 +493,7 @@ StrSpn (
return Count;
}
Count ++;
Count++;
}
return Count;
@ -499,17 +511,17 @@ StrSpn (
CHAR16 *
EFIAPI
StrBrk (
IN CHAR16 *String,
IN CHAR16 *CharSet
IN CHAR16 *String,
IN CHAR16 *CharSet
)
{
CHAR16 *Str1;
CHAR16 *Str2;
for (Str1 = String; *Str1 != L'\0'; Str1 ++) {
for (Str2 = CharSet; *Str2 != L'\0'; Str2 ++) {
for (Str1 = String; *Str1 != L'\0'; Str1++) {
for (Str2 = CharSet; *Str2 != L'\0'; Str2++) {
if (*Str1 == *Str2) {
return (CHAR16 *) Str1;
return (CHAR16 *)Str1;
}
}
}
@ -528,8 +540,8 @@ StrBrk (
CHAR16 *
EFIAPI
StrTokenLine (
IN CHAR16 *String OPTIONAL,
IN CHAR16 *CharSet
IN CHAR16 *String OPTIONAL,
IN CHAR16 *CharSet
)
{
CHAR16 *Begin;
@ -549,7 +561,7 @@ StrTokenLine (
End = StrBrk (Begin, CharSet);
if ((End != NULL) && (*End != L'\0')) {
*End = L'\0';
End ++;
End++;
}
mLineBuffer = End;
@ -567,14 +579,13 @@ StrTokenLine (
CHAR16 *
EFIAPI
StrTokenField (
IN CHAR16 *String OPTIONAL,
IN CHAR16 *CharSet
IN CHAR16 *String OPTIONAL,
IN CHAR16 *CharSet
)
{
CHAR16 *Begin;
CHAR16 *End;
Begin = (String == NULL) ? mFieldBuffer : String;
if (Begin == NULL) {
return NULL;
@ -588,7 +599,7 @@ StrTokenField (
End = StrBrk (Begin, CharSet);
if ((End != NULL) && (*End != L'\0')) {
*End = L'\0';
End ++;
End++;
}
mFieldBuffer = End;
@ -606,8 +617,8 @@ StrTokenField (
CHAR16 *
EFIAPI
StrGetNewTokenLine (
IN CHAR16 *String,
IN CHAR16 *CharSet
IN CHAR16 *String,
IN CHAR16 *CharSet
)
{
return StrTokenLine (String, CharSet);
@ -623,7 +634,7 @@ StrGetNewTokenLine (
CHAR16 *
EFIAPI
StrGetNextTokenLine (
IN CHAR16 *CharSet
IN CHAR16 *CharSet
)
{
return StrTokenLine (NULL, CharSet);
@ -640,8 +651,8 @@ StrGetNextTokenLine (
CHAR16 *
EFIAPI
StrGetNewTokenField (
IN CHAR16 *String,
IN CHAR16 *CharSet
IN CHAR16 *String,
IN CHAR16 *CharSet
)
{
return StrTokenField (String, CharSet);
@ -657,7 +668,7 @@ StrGetNewTokenField (
CHAR16 *
EFIAPI
StrGetNextTokenField (
IN CHAR16 *CharSet
IN CHAR16 *CharSet
)
{
return StrTokenField (NULL, CharSet);
@ -674,23 +685,24 @@ StrGetNextTokenField (
VOID
EFIAPI
PatchForStrTokenAfter (
IN CHAR16 *Buffer,
IN CHAR16 Patch
IN CHAR16 *Buffer,
IN CHAR16 Patch
)
{
CHAR16 *Str;
CHAR16 *Str;
if (Buffer == NULL) {
return ;
return;
}
Str = Buffer;
while (*Str != 0) {
Str ++;
Str++;
}
*Str = Patch;
while (*(Str ++) != '\0') {
while (*(Str++) != '\0') {
if (*Str == 0) {
*Str = Patch;
} else {
@ -698,7 +710,7 @@ PatchForStrTokenAfter (
}
}
return ;
return;
}
/**
@ -711,18 +723,18 @@ PatchForStrTokenAfter (
VOID
EFIAPI
PatchForStrTokenBefore (
IN CHAR16 *Buffer,
IN CHAR16 Patch
IN CHAR16 *Buffer,
IN CHAR16 Patch
)
{
CHAR16 *Str;
CHAR16 *Str;
if (Buffer == NULL) {
return ;
return;
}
Str = Buffer;
while (*(Str --) != '\0') {
while (*(Str--) != '\0') {
if ((*Str == 0) || (*Str == Patch)) {
*Str = Patch;
} else {
@ -730,11 +742,11 @@ PatchForStrTokenBefore (
}
}
return ;
return;
}
CHAR8 *mAsciiLineBuffer = NULL;
CHAR8 *mAsciiFieldBuffer = NULL;
CHAR8 *mAsciiLineBuffer = NULL;
CHAR8 *mAsciiFieldBuffer = NULL;
/**
@ -747,18 +759,18 @@ CHAR8 *mAsciiFieldBuffer = NULL;
UINTN
EFIAPI
AsciiStrSpn (
IN CHAR8 *String,
IN CHAR8 *CharSet
IN CHAR8 *String,
IN CHAR8 *CharSet
)
{
UINTN Count;
UINTN Count;
CHAR8 *Str1;
CHAR8 *Str2;
Count = 0;
for (Str1 = String; *Str1 != '\0'; Str1 ++) {
for (Str2 = CharSet; *Str2 != '\0'; Str2 ++) {
for (Str1 = String; *Str1 != '\0'; Str1++) {
for (Str2 = CharSet; *Str2 != '\0'; Str2++) {
if (*Str1 == *Str2) {
break;
}
@ -768,7 +780,7 @@ AsciiStrSpn (
return Count;
}
Count ++;
Count++;
}
return Count;
@ -785,17 +797,17 @@ AsciiStrSpn (
CHAR8 *
EFIAPI
AsciiStrBrk (
IN CHAR8 *String,
IN CHAR8 *CharSet
IN CHAR8 *String,
IN CHAR8 *CharSet
)
{
CHAR8 *Str1;
CHAR8 *Str2;
for (Str1 = String; *Str1 != '\0'; Str1 ++) {
for (Str2 = CharSet; *Str2 != '\0'; Str2 ++) {
for (Str1 = String; *Str1 != '\0'; Str1++) {
for (Str2 = CharSet; *Str2 != '\0'; Str2++) {
if (*Str1 == *Str2) {
return (CHAR8 *) Str1;
return (CHAR8 *)Str1;
}
}
}
@ -814,8 +826,8 @@ AsciiStrBrk (
CHAR8 *
EFIAPI
AsciiStrTokenLine (
IN CHAR8 *String OPTIONAL,
IN CHAR8 *CharSet
IN CHAR8 *String OPTIONAL,
IN CHAR8 *CharSet
)
{
CHAR8 *Begin;
@ -835,7 +847,7 @@ AsciiStrTokenLine (
End = AsciiStrBrk (Begin, CharSet);
if ((End != NULL) && (*End != '\0')) {
*End = '\0';
End ++;
End++;
}
mAsciiLineBuffer = End;
@ -853,14 +865,13 @@ AsciiStrTokenLine (
CHAR8 *
EFIAPI
AsciiStrTokenField (
IN CHAR8 *String OPTIONAL,
IN CHAR8 *CharSet
IN CHAR8 *String OPTIONAL,
IN CHAR8 *CharSet
)
{
CHAR8 *Begin;
CHAR8 *End;
Begin = (String == NULL) ? mAsciiFieldBuffer : String;
if (Begin == NULL) {
return NULL;
@ -874,7 +885,7 @@ AsciiStrTokenField (
End = AsciiStrBrk (Begin, CharSet);
if ((End != NULL) && (*End != '\0')) {
*End = '\0';
End ++;
End++;
}
mAsciiFieldBuffer = End;
@ -892,8 +903,8 @@ AsciiStrTokenField (
CHAR8 *
EFIAPI
AsciiStrGetNewTokenLine (
IN CHAR8 *String,
IN CHAR8 *CharSet
IN CHAR8 *String,
IN CHAR8 *CharSet
)
{
return AsciiStrTokenLine (String, CharSet);
@ -909,7 +920,7 @@ AsciiStrGetNewTokenLine (
CHAR8 *
EFIAPI
AsciiStrGetNextTokenLine (
IN CHAR8 *CharSet
IN CHAR8 *CharSet
)
{
return AsciiStrTokenLine (NULL, CharSet);
@ -926,8 +937,8 @@ AsciiStrGetNextTokenLine (
CHAR8 *
EFIAPI
AsciiStrGetNewTokenField (
IN CHAR8 *String,
IN CHAR8 *CharSet
IN CHAR8 *String,
IN CHAR8 *CharSet
)
{
return AsciiStrTokenField (String, CharSet);
@ -943,7 +954,7 @@ AsciiStrGetNewTokenField (
CHAR8 *
EFIAPI
AsciiStrGetNextTokenField (
IN CHAR8 *CharSet
IN CHAR8 *CharSet
)
{
return AsciiStrTokenField (NULL, CharSet);
@ -960,23 +971,24 @@ AsciiStrGetNextTokenField (
VOID
EFIAPI
PatchForAsciiStrTokenAfter (
IN CHAR8 *Buffer,
IN CHAR8 Patch
IN CHAR8 *Buffer,
IN CHAR8 Patch
)
{
CHAR8 *Str;
CHAR8 *Str;
if (Buffer == NULL) {
return ;
return;
}
Str = Buffer;
while (*Str != 0) {
Str ++;
Str++;
}
*Str = Patch;
while (*(Str ++) != '\0') {
while (*(Str++) != '\0') {
if (*Str == 0) {
*Str = Patch;
} else {
@ -984,7 +996,7 @@ PatchForAsciiStrTokenAfter (
}
}
return ;
return;
}
/**
@ -997,18 +1009,18 @@ PatchForAsciiStrTokenAfter (
VOID
EFIAPI
PatchForAsciiStrTokenBefore (
IN CHAR8 *Buffer,
IN CHAR8 Patch
IN CHAR8 *Buffer,
IN CHAR8 Patch
)
{
CHAR8 *Str;
CHAR8 *Str;
if (Buffer == NULL) {
return ;
return;
}
Str = Buffer;
while (*(Str --) != '\0') {
while (*(Str--) != '\0') {
if ((*Str == 0) || (*Str == Patch)) {
*Str = Patch;
} else {
@ -1016,5 +1028,5 @@ PatchForAsciiStrTokenBefore (
}
}
return ;
return;
}

View File

@ -48,8 +48,8 @@ SetCursorPosition (
EFI_STATUS
EFIAPI
WaitForSingleEvent (
IN EFI_EVENT Event,
IN UINT64 Timeout OPTIONAL
IN EFI_EVENT Event,
IN UINT64 Timeout OPTIONAL
)
{
EFI_STATUS Status;
@ -67,10 +67,10 @@ WaitForSingleEvent (
// Set the timer event
//
gBS->SetTimer (
TimerEvent,
TimerRelative,
Timeout
);
TimerEvent,
TimerRelative,
Timeout
);
//
// Wait for the original event or the timer
@ -83,7 +83,7 @@ WaitForSingleEvent (
//
// If the timer expired, change the return to timed out
//
if (!EFI_ERROR (Status) && Index == 1) {
if (!EFI_ERROR (Status) && (Index == 1)) {
Status = EFI_TIMEOUT;
}
}
@ -111,9 +111,9 @@ WaitForSingleEvent (
VOID
EFIAPI
ConMoveCursorBackward (
IN UINTN LineLength,
IN OUT UINTN *Column,
IN OUT UINTN *Row
IN UINTN LineLength,
IN OUT UINTN *Column,
IN OUT UINTN *Row
)
{
ASSERT (Column != NULL);
@ -149,10 +149,10 @@ ConMoveCursorBackward (
VOID
EFIAPI
ConMoveCursorForward (
IN UINTN LineLength,
IN UINTN TotalRow,
IN OUT UINTN *Column,
IN OUT UINTN *Row
IN UINTN LineLength,
IN UINTN TotalRow,
IN OUT UINTN *Column,
IN OUT UINTN *Row
)
{
ASSERT (Column != NULL);
@ -170,8 +170,8 @@ ConMoveCursorForward (
}
}
CHAR16 mBackupSpace[EFI_DEBUG_INPUS_BUFFER_SIZE];
CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE];
CHAR16 mBackupSpace[EFI_DEBUG_INPUS_BUFFER_SIZE];
CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE];
/**
@ -185,36 +185,36 @@ CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE];
VOID
EFIAPI
Input (
IN CHAR16 *Prompt OPTIONAL,
OUT CHAR16 *InStr,
IN UINTN StrLength
IN CHAR16 *Prompt OPTIONAL,
OUT CHAR16 *InStr,
IN UINTN StrLength
)
{
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
BOOLEAN Done;
UINTN Column;
UINTN Row;
UINTN StartColumn;
UINTN Update;
UINTN Delete;
UINTN Len;
UINTN StrPos;
UINTN Index;
UINTN LineLength;
UINTN TotalRow;
UINTN SkipLength;
UINTN OutputLength;
UINTN TailRow;
UINTN TailColumn;
EFI_INPUT_KEY Key;
BOOLEAN InsertMode;
BOOLEAN NeedAdjust;
UINTN SubIndex;
CHAR16 *CommandStr;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
BOOLEAN Done;
UINTN Column;
UINTN Row;
UINTN StartColumn;
UINTN Update;
UINTN Delete;
UINTN Len;
UINTN StrPos;
UINTN Index;
UINTN LineLength;
UINTN TotalRow;
UINTN SkipLength;
UINTN OutputLength;
UINTN TailRow;
UINTN TailColumn;
EFI_INPUT_KEY Key;
BOOLEAN InsertMode;
BOOLEAN NeedAdjust;
UINTN SubIndex;
CHAR16 *CommandStr;
ConOut = gST->ConOut;
ConIn = gST->ConIn;
ConIn = gST->ConIn;
ASSERT (ConOut != NULL);
ASSERT (ConIn != NULL);
@ -223,23 +223,25 @@ Input (
if (Prompt != NULL) {
ConOut->OutputString (ConOut, Prompt);
}
//
// Read a line from the console
//
Len = 0;
StrPos = 0;
OutputLength = 0;
Update = 0;
Delete = 0;
InsertMode = TRUE;
NeedAdjust = FALSE;
Len = 0;
StrPos = 0;
OutputLength = 0;
Update = 0;
Delete = 0;
InsertMode = TRUE;
NeedAdjust = FALSE;
//
// If buffer is not large enough to hold a CHAR16, do nothing.
//
if (StrLength < 1) {
return ;
return;
}
//
// Get the screen setting and the current cursor location
//
@ -248,7 +250,7 @@ Input (
Row = ConOut->Mode->CursorRow;
ConOut->QueryMode (ConOut, ConOut->Mode->Mode, &LineLength, &TotalRow);
if (LineLength == 0) {
return ;
return;
}
SetMem (InStr, StrLength * sizeof (CHAR16), 0);
@ -261,191 +263,200 @@ Input (
ConIn->ReadKeyStroke (ConIn, &Key);
switch (Key.UnicodeChar) {
case CHAR_CARRIAGE_RETURN:
//
// All done, print a newline at the end of the string
//
TailRow = Row + (Len - StrPos + Column) / LineLength;
TailColumn = (Len - StrPos + Column) % LineLength;
Done = TRUE;
break;
case CHAR_CARRIAGE_RETURN:
//
// All done, print a newline at the end of the string
//
TailRow = Row + (Len - StrPos + Column) / LineLength;
TailColumn = (Len - StrPos + Column) % LineLength;
Done = TRUE;
break;
case CHAR_BACKSPACE:
if (StrPos != 0) {
//
// If not move back beyond string beginning, move all characters behind
// the current position one character forward
//
StrPos -= 1;
Update = StrPos;
Delete = 1;
CopyMem (InStr + StrPos, InStr + StrPos + 1, sizeof (CHAR16) * (Len - StrPos));
//
// Adjust the current column and row
//
ConMoveCursorBackward (LineLength, &Column, &Row);
NeedAdjust = TRUE;
}
break;
default:
if (Key.UnicodeChar >= ' ') {
//
// If we are at the buffer's end, drop the key
//
if (Len == StrLength - 1 && (InsertMode || StrPos == Len)) {
break;
}
//
// If in insert mode, move all characters behind the current position
// one character backward to make space for this character. Then store
// the character.
//
if (InsertMode) {
for (Index = Len; Index > StrPos; Index -= 1) {
InStr[Index] = InStr[Index - 1];
}
}
InStr[StrPos] = Key.UnicodeChar;
Update = StrPos;
StrPos += 1;
OutputLength = 1;
}
break;
case 0:
switch (Key.ScanCode) {
case SCAN_DELETE:
//
// Move characters behind current position one character forward
//
if (Len != 0) {
case CHAR_BACKSPACE:
if (StrPos != 0) {
//
// If not move back beyond string beginning, move all characters behind
// the current position one character forward
//
StrPos -= 1;
Update = StrPos;
Delete = 1;
CopyMem (InStr + StrPos, InStr + StrPos + 1, sizeof (CHAR16) * (Len - StrPos));
//
// Adjust the current column and row
//
ConMoveCursorBackward (LineLength, &Column, &Row);
NeedAdjust = TRUE;
}
break;
case SCAN_LEFT:
//
// Adjust current cursor position
//
if (StrPos != 0) {
StrPos -= 1;
ConMoveCursorBackward (LineLength, &Column, &Row);
default:
if (Key.UnicodeChar >= ' ') {
//
// If we are at the buffer's end, drop the key
//
if ((Len == StrLength - 1) && (InsertMode || (StrPos == Len))) {
break;
}
//
// If in insert mode, move all characters behind the current position
// one character backward to make space for this character. Then store
// the character.
//
if (InsertMode) {
for (Index = Len; Index > StrPos; Index -= 1) {
InStr[Index] = InStr[Index - 1];
}
}
InStr[StrPos] = Key.UnicodeChar;
Update = StrPos;
StrPos += 1;
OutputLength = 1;
}
break;
case SCAN_RIGHT:
//
// Adjust current cursor position
//
if (StrPos < Len) {
StrPos += 1;
ConMoveCursorForward (LineLength, TotalRow, &Column, &Row);
case 0:
switch (Key.ScanCode) {
case SCAN_DELETE:
//
// Move characters behind current position one character forward
//
if (Len != 0) {
Update = StrPos;
Delete = 1;
CopyMem (InStr + StrPos, InStr + StrPos + 1, sizeof (CHAR16) * (Len - StrPos));
NeedAdjust = TRUE;
}
break;
case SCAN_LEFT:
//
// Adjust current cursor position
//
if (StrPos != 0) {
StrPos -= 1;
ConMoveCursorBackward (LineLength, &Column, &Row);
}
break;
case SCAN_RIGHT:
//
// Adjust current cursor position
//
if (StrPos < Len) {
StrPos += 1;
ConMoveCursorForward (LineLength, TotalRow, &Column, &Row);
}
break;
case SCAN_HOME:
//
// Move current cursor position to the beginning of the command line
//
Row -= (StrPos + StartColumn) / LineLength;
Column = StartColumn;
StrPos = 0;
break;
case SCAN_END:
//
// Move current cursor position to the end of the command line
//
TailRow = Row + (Len - StrPos + Column) / LineLength;
TailColumn = (Len - StrPos + Column) % LineLength;
Row = TailRow;
Column = TailColumn;
StrPos = Len;
break;
case SCAN_ESC:
//
// Prepare to clear the current command line
//
InStr[0] = 0;
Update = 0;
Delete = Len;
Row -= (StrPos + StartColumn) / LineLength;
Column = StartColumn;
OutputLength = 0;
NeedAdjust = TRUE;
break;
case SCAN_INSERT:
//
// Toggle the SEnvInsertMode flag
//
InsertMode = (BOOLEAN) !InsertMode;
break;
case SCAN_UP:
case SCAN_DOWN:
//
// show history
//
CopyMem (InStr, mInputBufferHistory, StrLength * sizeof (CHAR16));
StrPos = StrLen (mInputBufferHistory);
Update = 0;
Delete = 0;
OutputLength = 0;
TailRow = Row + (StrPos + StartColumn) / LineLength;
TailColumn = (StrPos + StartColumn) % LineLength;
Row = TailRow;
Column = TailColumn;
NeedAdjust = FALSE;
ConOut->SetCursorPosition (ConOut, StartColumn, Row);
for (SubIndex = 0; SubIndex < EFI_DEBUG_INPUS_BUFFER_SIZE - (StartColumn - EFI_DEBUG_PROMPT_COLUMN); SubIndex++) {
mBackupSpace[SubIndex] = L' ';
}
EDBPrint (mBackupSpace);
SetMem (mBackupSpace, (EFI_DEBUG_INPUS_BUFFER_SIZE - (StartColumn - EFI_DEBUG_PROMPT_COLUMN)) * sizeof (CHAR16), 0);
ConOut->SetCursorPosition (ConOut, StartColumn, Row);
Len = StrPos;
break;
case SCAN_F1:
case SCAN_F2:
case SCAN_F3:
case SCAN_F4:
case SCAN_F5:
case SCAN_F6:
case SCAN_F7:
case SCAN_F8:
case SCAN_F9:
case SCAN_F10:
case SCAN_F11:
case SCAN_F12:
CommandStr = GetCommandNameByKey (Key);
if (CommandStr != NULL) {
StrnCpyS (InStr, StrLength, CommandStr, StrLength - 1);
return;
}
break;
}
break;
case SCAN_HOME:
//
// Move current cursor position to the beginning of the command line
//
Row -= (StrPos + StartColumn) / LineLength;
Column = StartColumn;
StrPos = 0;
break;
case SCAN_END:
//
// Move current cursor position to the end of the command line
//
TailRow = Row + (Len - StrPos + Column) / LineLength;
TailColumn = (Len - StrPos + Column) % LineLength;
Row = TailRow;
Column = TailColumn;
StrPos = Len;
break;
case SCAN_ESC:
//
// Prepare to clear the current command line
//
InStr[0] = 0;
Update = 0;
Delete = Len;
Row -= (StrPos + StartColumn) / LineLength;
Column = StartColumn;
OutputLength = 0;
NeedAdjust = TRUE;
break;
case SCAN_INSERT:
//
// Toggle the SEnvInsertMode flag
//
InsertMode = (BOOLEAN)!InsertMode;
break;
case SCAN_UP:
case SCAN_DOWN:
//
// show history
//
CopyMem (InStr, mInputBufferHistory, StrLength * sizeof(CHAR16));
StrPos = StrLen (mInputBufferHistory);
Update = 0;
Delete = 0;
OutputLength = 0;
TailRow = Row + (StrPos + StartColumn) / LineLength;
TailColumn = (StrPos + StartColumn) % LineLength;
Row = TailRow;
Column = TailColumn;
NeedAdjust = FALSE;
ConOut->SetCursorPosition (ConOut, StartColumn, Row);
for (SubIndex = 0; SubIndex < EFI_DEBUG_INPUS_BUFFER_SIZE - (StartColumn - EFI_DEBUG_PROMPT_COLUMN); SubIndex++) {
mBackupSpace[SubIndex] = L' ';
}
EDBPrint (mBackupSpace);
SetMem (mBackupSpace, (EFI_DEBUG_INPUS_BUFFER_SIZE - (StartColumn - EFI_DEBUG_PROMPT_COLUMN)) * sizeof(CHAR16), 0);
ConOut->SetCursorPosition (ConOut, StartColumn, Row);
Len = StrPos;
break;
case SCAN_F1:
case SCAN_F2:
case SCAN_F3:
case SCAN_F4:
case SCAN_F5:
case SCAN_F6:
case SCAN_F7:
case SCAN_F8:
case SCAN_F9:
case SCAN_F10:
case SCAN_F11:
case SCAN_F12:
CommandStr = GetCommandNameByKey (Key);
if (CommandStr != NULL) {
StrnCpyS (InStr, StrLength, CommandStr, StrLength - 1);
return ;
}
break;
}
}
if (Done) {
break;
}
//
// If we need to update the output do so now
//
@ -455,11 +466,13 @@ Input (
for (SubIndex = 0; SubIndex < EFI_DEBUG_INPUS_BUFFER_SIZE - (Column - EFI_DEBUG_PROMPT_COLUMN); SubIndex++) {
mBackupSpace[SubIndex] = L' ';
}
EDBPrint (mBackupSpace);
SetMem (mBackupSpace, (EFI_DEBUG_INPUS_BUFFER_SIZE - (Column - EFI_DEBUG_PROMPT_COLUMN)) * sizeof(CHAR16), 0);
SetMem (mBackupSpace, (EFI_DEBUG_INPUS_BUFFER_SIZE - (Column - EFI_DEBUG_PROMPT_COLUMN)) * sizeof (CHAR16), 0);
ConOut->SetCursorPosition (ConOut, Column, Row);
NeedAdjust = FALSE;
}
EDBPrint (InStr + Update);
Len = StrLen (InStr);
@ -471,19 +484,19 @@ Input (
StrPos = Len;
}
Update = (UINTN) -1;
Update = (UINTN)-1;
//
// After using print to reflect newly updates, if we're not using
// BACKSPACE and DELETE, we need to move the cursor position forward,
// so adjust row and column here.
//
if (Key.UnicodeChar != CHAR_BACKSPACE && !(Key.UnicodeChar == 0 && Key.ScanCode == SCAN_DELETE)) {
if ((Key.UnicodeChar != CHAR_BACKSPACE) && !((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_DELETE))) {
//
// Calulate row and column of the tail of current string
//
TailRow = Row + (Len - StrPos + Column + OutputLength) / LineLength;
TailColumn = (Len - StrPos + Column + OutputLength) % LineLength;
TailRow = Row + (Len - StrPos + Column + OutputLength) / LineLength;
TailColumn = (Len - StrPos + Column + OutputLength) % LineLength;
//
// If the tail of string reaches screen end, screen rolls up, so if
@ -492,9 +505,10 @@ Input (
// (if we are recalling commands using UPPER and DOWN key, and if the
// old command is too long to fit the screen, TailColumn must be 79.
//
if (TailColumn == 0 && TailRow >= TotalRow && (UINTN) Row != TailRow) {
if ((TailColumn == 0) && (TailRow >= TotalRow) && ((UINTN)Row != TailRow)) {
Row--;
}
//
// Calculate the cursor position after current operation. If cursor
// reaches line end, update both row and column, otherwise, only
@ -504,7 +518,7 @@ Input (
SkipLength = OutputLength - (LineLength - Column);
Row += SkipLength / LineLength + 1;
if ((UINTN) Row > TotalRow - 1) {
if ((UINTN)Row > TotalRow - 1) {
Row = TotalRow - 1;
}
@ -516,18 +530,19 @@ Input (
Delete = 0;
}
//
// Set the cursor position for this key
//
SetCursorPosition (ConOut, Column, Row, LineLength, TotalRow, InStr, StrPos, Len);
} while (!Done);
CopyMem (mInputBufferHistory, InStr, StrLength * sizeof(CHAR16));
CopyMem (mInputBufferHistory, InStr, StrLength * sizeof (CHAR16));
//
// Return the data to the caller
//
return ;
return;
}
/**
@ -546,14 +561,14 @@ Input (
VOID
EFIAPI
SetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,
IN UINTN Column,
IN INTN Row,
IN UINTN LineLength,
IN UINTN TotalRow,
IN CHAR16 *Str,
IN UINTN StrPos,
IN UINTN Len
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,
IN UINTN Column,
IN INTN Row,
IN UINTN LineLength,
IN UINTN TotalRow,
IN CHAR16 *Str,
IN UINTN StrPos,
IN UINTN Len
)
{
CHAR16 Backup;
@ -564,12 +579,12 @@ SetCursorPosition (
Backup = 0;
if (Row >= 0) {
ConOut->SetCursorPosition (ConOut, Column, Row);
return ;
return;
}
if (Len - StrPos > Column * Row) {
Backup = *(Str + StrPos + Column * Row);
*(Str + StrPos + Column * Row) = 0;
Backup = *(Str + StrPos + Column * Row);
*(Str + StrPos + Column * Row) = 0;
}
EDBPrint (L"%s", Str + StrPos);
@ -591,9 +606,9 @@ SetPageBreak (
VOID
)
{
EFI_INPUT_KEY Key;
CHAR16 Str[3];
BOOLEAN OmitPrint;
EFI_INPUT_KEY Key;
CHAR16 Str[3];
BOOLEAN OmitPrint;
//
// Check
@ -608,10 +623,10 @@ SetPageBreak (
//
// Wait for user input
//
Str[0] = ' ';
Str[1] = 0;
Str[2] = 0;
for (;;) {
Str[0] = ' ';
Str[1] = 0;
Str[2] = 0;
for ( ; ;) {
WaitForSingleEvent (gST->ConIn->WaitForKey, 0);
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
@ -632,6 +647,7 @@ SetPageBreak (
gST->ConOut->OutputString (gST->ConOut, L"\r\n");
break;
}
//
// Echo input
//
@ -669,9 +685,9 @@ EDBPrint (
...
)
{
UINTN Return;
VA_LIST Marker;
CHAR16 Buffer[EFI_DEBUG_MAX_PRINT_BUFFER];
UINTN Return;
VA_LIST Marker;
CHAR16 Buffer[EFI_DEBUG_MAX_PRINT_BUFFER];
VA_START (Marker, Format);
Return = UnicodeVSPrint (Buffer, sizeof (Buffer), Format, Marker);
@ -707,8 +723,8 @@ EDBSPrint (
...
)
{
UINTN Return;
VA_LIST Marker;
UINTN Return;
VA_LIST Marker;
ASSERT (BufferSize > 0);
@ -741,13 +757,13 @@ EDBSPrintWithOffset (
...
)
{
UINTN Return;
VA_LIST Marker;
UINTN Return;
VA_LIST Marker;
ASSERT (BufferSize - (Offset * sizeof(CHAR16)) > 0);
ASSERT (BufferSize - (Offset * sizeof (CHAR16)) > 0);
VA_START (Marker, Format);
Return = UnicodeVSPrint (Buffer + Offset, (UINTN)(BufferSize - (Offset * sizeof(CHAR16))), Format, Marker);
Return = UnicodeVSPrint (Buffer + Offset, (UINTN)(BufferSize - (Offset * sizeof (CHAR16))), Format, Marker);
VA_END (Marker);
return Return;

File diff suppressed because it is too large Load Diff

View File

@ -47,10 +47,10 @@ typedef enum {
**/
UINTN
EbdFindSymbolAddress (
IN UINTN Address,
IN EDB_MATCH_SYMBOL_TYPE Type,
OUT EFI_DEBUGGER_SYMBOL_OBJECT **Object,
OUT EFI_DEBUGGER_SYMBOL_ENTRY **Entry
IN UINTN Address,
IN EDB_MATCH_SYMBOL_TYPE Type,
OUT EFI_DEBUGGER_SYMBOL_OBJECT **Object,
OUT EFI_DEBUGGER_SYMBOL_ENTRY **Entry
);
/**
@ -67,10 +67,10 @@ EbdFindSymbolAddress (
**/
EFI_STATUS
EdbLoadSymbol (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
IN UINTN BufferSize,
IN VOID *Buffer
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
IN UINTN BufferSize,
IN VOID *Buffer
);
/**
@ -85,8 +85,8 @@ EdbLoadSymbol (
**/
EFI_STATUS
EdbUnloadSymbol (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName
);
/**
@ -103,9 +103,9 @@ EdbUnloadSymbol (
**/
EFI_STATUS
EdbPatchSymbolRVA (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *FileName,
IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType
);
/**
@ -123,11 +123,11 @@ EdbPatchSymbolRVA (
**/
EFI_STATUS
EdbLoadCode (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *FileName,
IN UINTN BufferSize,
IN VOID *Buffer
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *FileName,
IN UINTN BufferSize,
IN VOID *Buffer
);
/**
@ -144,10 +144,10 @@ EdbLoadCode (
**/
EFI_STATUS
EdbUnloadCode (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *FileName,
OUT VOID **Buffer
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *FileName,
OUT VOID **Buffer
);
/**
@ -165,11 +165,11 @@ EdbUnloadCode (
**/
EFI_STATUS
EdbAddCodeBuffer (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *CodeFileName,
IN UINTN SourceBufferSize,
IN VOID *SourceBuffer
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *CodeFileName,
IN UINTN SourceBufferSize,
IN VOID *SourceBuffer
);
/**
@ -186,10 +186,10 @@ EdbAddCodeBuffer (
**/
EFI_STATUS
EdbDeleteCodeBuffer (
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *CodeFileName,
IN VOID *SourceBuffer
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
IN CHAR16 *MapFileName,
IN CHAR16 *CodeFileName,
IN VOID *SourceBuffer
);
/**
@ -203,7 +203,7 @@ EdbDeleteCodeBuffer (
**/
CHAR8 *
FindSymbolStr (
IN UINTN Address
IN UINTN Address
);
/**
@ -219,8 +219,8 @@ FindSymbolStr (
**/
UINTN
EdbPrintSource (
IN UINTN Address,
IN BOOLEAN IsPrint
IN UINTN Address,
IN BOOLEAN IsPrint
);
/**
@ -237,8 +237,8 @@ EdbPrintSource (
**/
EFI_STATUS
Symboltoi (
IN CHAR16 *Symbol,
OUT UINTN *Address
IN CHAR16 *Symbol,
OUT UINTN *Address
);
#endif