diff options
Diffstat (limited to 'MdeModulePkg/Universal/EbcDxe')
39 files changed, 4533 insertions, 4284 deletions
diff --git a/MdeModulePkg/Universal/EbcDxe/AArch64/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/AArch64/EbcSupport.c index a9512bd851..6622eace98 100644 --- a/MdeModulePkg/Universal/EbcDxe/AArch64/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/AArch64/EbcSupport.c @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Amount of space that is not used in the stack
//
-#define STACK_REMAIN_SIZE (1024 * 4)
+#define STACK_REMAIN_SIZE (1024 * 4)
#pragma pack(1)
typedef struct {
@@ -28,7 +28,7 @@ typedef struct { } EBC_INSTRUCTION_BUFFER;
#pragma pack()
-extern CONST EBC_INSTRUCTION_BUFFER mEbcInstructionBufferTemplate;
+extern CONST EBC_INSTRUCTION_BUFFER mEbcInstructionBufferTemplate;
/**
Begin executing an EBC image.
@@ -65,20 +65,19 @@ EbcLLExecuteEbcImageEntryPoint ( **/
VOID
PushU64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Arg
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Arg
)
{
//
// Advance the VM stack down, and then copy the argument to the stack.
// Hope it's aligned.
//
- VmPtr->Gpr[0] -= sizeof (UINT64);
- *(UINT64 *) VmPtr->Gpr[0] = Arg;
+ VmPtr->Gpr[0] -= sizeof (UINT64);
+ *(UINT64 *)VmPtr->Gpr[0] = Arg;
return;
}
-
/**
Begin executing an EBC image.
@@ -129,12 +128,12 @@ EbcInterpret ( //
// Now clear out our context
//
- ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));
+ ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));
//
// Set the VM instruction pointer to the correct location in memory.
//
- VmContext.Ip = (VMIP) Addr;
+ VmContext.Ip = (VMIP)Addr;
//
// Initialize the stack pointer for the EBC. Get the current system stack
@@ -145,14 +144,15 @@ EbcInterpret ( // Adjust the VM's stack pointer down.
//
- Status = GetEBCStack((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);
- if (EFI_ERROR(Status)) {
+ Status = GetEBCStack ((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);
+ if (EFI_ERROR (Status)) {
return Status;
}
- VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);
- VmContext.Gpr[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);
- VmContext.HighStackBottom = (UINTN) VmContext.Gpr[0];
- VmContext.Gpr[0] -= sizeof (UINTN);
+
+ VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
+ VmContext.Gpr[0] = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
+ VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];
+ VmContext.Gpr[0] -= sizeof (UINTN);
//
// Align the stack on a natural boundary.
@@ -162,46 +162,46 @@ EbcInterpret ( //
// Put a magic value in the stack gap, then adjust down again.
//
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;
- VmContext.StackMagicPtr = (UINTN *) (UINTN) VmContext.Gpr[0];
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;
+ VmContext.StackMagicPtr = (UINTN *)(UINTN)VmContext.Gpr[0];
//
// The stack upper to LowStackTop is belong to the VM.
//
- VmContext.LowStackTop = (UINTN) VmContext.Gpr[0];
+ VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];
//
// For the worst case, assume there are 4 arguments passed in registers, store
// them to VM's stack.
//
- PushU64 (&VmContext, (UINT64) Args9_16[7]);
- PushU64 (&VmContext, (UINT64) Args9_16[6]);
- PushU64 (&VmContext, (UINT64) Args9_16[5]);
- PushU64 (&VmContext, (UINT64) Args9_16[4]);
- PushU64 (&VmContext, (UINT64) Args9_16[3]);
- PushU64 (&VmContext, (UINT64) Args9_16[2]);
- PushU64 (&VmContext, (UINT64) Args9_16[1]);
- PushU64 (&VmContext, (UINT64) Args9_16[0]);
- PushU64 (&VmContext, (UINT64) Arg8);
- PushU64 (&VmContext, (UINT64) Arg7);
- PushU64 (&VmContext, (UINT64) Arg6);
- PushU64 (&VmContext, (UINT64) Arg5);
- PushU64 (&VmContext, (UINT64) Arg4);
- PushU64 (&VmContext, (UINT64) Arg3);
- PushU64 (&VmContext, (UINT64) Arg2);
- PushU64 (&VmContext, (UINT64) Arg1);
+ PushU64 (&VmContext, (UINT64)Args9_16[7]);
+ PushU64 (&VmContext, (UINT64)Args9_16[6]);
+ PushU64 (&VmContext, (UINT64)Args9_16[5]);
+ PushU64 (&VmContext, (UINT64)Args9_16[4]);
+ PushU64 (&VmContext, (UINT64)Args9_16[3]);
+ PushU64 (&VmContext, (UINT64)Args9_16[2]);
+ PushU64 (&VmContext, (UINT64)Args9_16[1]);
+ PushU64 (&VmContext, (UINT64)Args9_16[0]);
+ PushU64 (&VmContext, (UINT64)Arg8);
+ PushU64 (&VmContext, (UINT64)Arg7);
+ PushU64 (&VmContext, (UINT64)Arg6);
+ PushU64 (&VmContext, (UINT64)Arg5);
+ PushU64 (&VmContext, (UINT64)Arg4);
+ PushU64 (&VmContext, (UINT64)Arg3);
+ PushU64 (&VmContext, (UINT64)Arg2);
+ PushU64 (&VmContext, (UINT64)Arg1);
//
// Interpreter assumes 64-bit return address is pushed on the stack.
// AArch64 does not do this so pad the stack accordingly.
//
- PushU64 (&VmContext, (UINT64) 0);
- PushU64 (&VmContext, (UINT64) 0x1234567887654321ULL);
+ PushU64 (&VmContext, (UINT64)0);
+ PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);
//
// For AArch64, this is where we say our return address is
//
- VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];
+ VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];
//
// We need to keep track of where the EBC stack starts. This way, if the EBC
@@ -226,11 +226,10 @@ EbcInterpret ( //
// Return the value in R[7] unless there was an error
//
- ReturnEBCStack(StackIndex);
- return (UINT64) VmContext.Gpr[7];
+ ReturnEBCStack (StackIndex);
+ return (UINT64)VmContext.Gpr[7];
}
-
/**
Begin executing an EBC image.
@@ -245,9 +244,9 @@ EbcInterpret ( UINT64
EFIAPI
ExecuteEbcImageEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN UINTN EntryPoint
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN UINTN EntryPoint
)
{
//
@@ -266,7 +265,7 @@ ExecuteEbcImageEntryPoint ( //
// Now clear out our context
//
- ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));
+ ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));
//
// Save the image handle so we can track the thunks created for this image
@@ -277,52 +276,52 @@ ExecuteEbcImageEntryPoint ( //
// Set the VM instruction pointer to the correct location in memory.
//
- VmContext.Ip = (VMIP) Addr;
+ VmContext.Ip = (VMIP)Addr;
//
// Initialize the stack pointer for the EBC. Get the current system stack
// pointer and adjust it down by the max needed for the interpreter.
//
- Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);
- if (EFI_ERROR(Status)) {
+ Status = GetEBCStack (ImageHandle, &VmContext.StackPool, &StackIndex);
+ if (EFI_ERROR (Status)) {
return Status;
}
- VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);
- VmContext.Gpr[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);
- VmContext.HighStackBottom = (UINTN) VmContext.Gpr[0];
- VmContext.Gpr[0] -= sizeof (UINTN);
+ VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
+ VmContext.Gpr[0] = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
+ VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];
+ VmContext.Gpr[0] -= sizeof (UINTN);
//
// Put a magic value in the stack gap, then adjust down again
//
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;
- VmContext.StackMagicPtr = (UINTN *) (UINTN) VmContext.Gpr[0];
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;
+ VmContext.StackMagicPtr = (UINTN *)(UINTN)VmContext.Gpr[0];
//
// Align the stack on a natural boundary
- VmContext.Gpr[0] &= ~(VM_REGISTER)(sizeof(UINTN) - 1);
+ VmContext.Gpr[0] &= ~(VM_REGISTER)(sizeof (UINTN) - 1);
//
- VmContext.LowStackTop = (UINTN) VmContext.Gpr[0];
+ VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];
//
// Simply copy the image handle and system table onto the EBC stack.
// Greatly simplifies things by not having to spill the args.
//
- PushU64 (&VmContext, (UINT64) SystemTable);
- PushU64 (&VmContext, (UINT64) ImageHandle);
+ PushU64 (&VmContext, (UINT64)SystemTable);
+ PushU64 (&VmContext, (UINT64)ImageHandle);
//
// VM pushes 16-bytes for return address. Simulate that here.
//
- PushU64 (&VmContext, (UINT64) 0);
- PushU64 (&VmContext, (UINT64) 0x1234567887654321ULL);
+ PushU64 (&VmContext, (UINT64)0);
+ PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);
//
// For AArch64, this is where we say our return address is
//
- VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];
+ VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];
//
// Entry function needn't access high stack context, simply
@@ -338,11 +337,10 @@ ExecuteEbcImageEntryPoint ( //
// Return the value in R[7] unless there was an error
//
- ReturnEBCStack(StackIndex);
- return (UINT64) VmContext.Gpr[7];
+ ReturnEBCStack (StackIndex);
+ return (UINT64)VmContext.Gpr[7];
}
-
/**
Create thunks for an EBC image entry point, or an EBC protocol service.
@@ -362,18 +360,18 @@ ExecuteEbcImageEntryPoint ( **/
EFI_STATUS
EbcCreateThunks (
- IN EFI_HANDLE ImageHandle,
- IN VOID *EbcEntryPoint,
- OUT VOID **Thunk,
- IN UINT32 Flags
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk,
+ IN UINT32 Flags
)
{
- EBC_INSTRUCTION_BUFFER *InstructionBuffer;
+ EBC_INSTRUCTION_BUFFER *InstructionBuffer;
//
// Check alignment of pointer to EBC code
//
- if ((UINT32) (UINTN) EbcEntryPoint & 0x01) {
+ if ((UINT32)(UINTN)EbcEntryPoint & 0x01) {
return EFI_INVALID_PARAMETER;
}
@@ -390,8 +388,11 @@ EbcCreateThunks ( //
// Copy whole thunk instruction buffer template
//
- CopyMem (InstructionBuffer, &mEbcInstructionBufferTemplate,
- sizeof (EBC_INSTRUCTION_BUFFER));
+ CopyMem (
+ InstructionBuffer,
+ &mEbcInstructionBufferTemplate,
+ sizeof (EBC_INSTRUCTION_BUFFER)
+ );
//
// Patch EbcEntryPoint and EbcLLEbcInterpret
@@ -407,13 +408,15 @@ EbcCreateThunks ( // Add the thunk to the list for this image. Do this last since the add
// function flushes the cache for us.
//
- EbcAddImageThunk (ImageHandle, InstructionBuffer,
- sizeof (EBC_INSTRUCTION_BUFFER));
+ EbcAddImageThunk (
+ ImageHandle,
+ InstructionBuffer,
+ sizeof (EBC_INSTRUCTION_BUFFER)
+ );
return EFI_SUCCESS;
}
-
/**
This function is called to execute an EBC CALLEX instruction.
The function check the callee's content to see whether it is common native
@@ -431,34 +434,38 @@ EbcCreateThunks ( **/
VOID
EbcLLCALLEX (
- IN VM_CONTEXT *VmPtr,
- IN UINTN FuncAddr,
- IN UINTN NewStackPointer,
- IN VOID *FramePtr,
- IN UINT8 Size
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN FuncAddr,
+ IN UINTN NewStackPointer,
+ IN VOID *FramePtr,
+ IN UINT8 Size
)
{
- CONST EBC_INSTRUCTION_BUFFER *InstructionBuffer;
+ CONST EBC_INSTRUCTION_BUFFER *InstructionBuffer;
//
// Processor specific code to check whether the callee is a thunk to EBC.
//
InstructionBuffer = (EBC_INSTRUCTION_BUFFER *)FuncAddr;
- if (CompareMem (InstructionBuffer, &mEbcInstructionBufferTemplate,
- sizeof(EBC_INSTRUCTION_BUFFER) - 2 * sizeof (UINT64)) == 0) {
+ if (CompareMem (
+ InstructionBuffer,
+ &mEbcInstructionBufferTemplate,
+ sizeof (EBC_INSTRUCTION_BUFFER) - 2 * sizeof (UINT64)
+ ) == 0)
+ {
//
// The callee is a thunk to EBC, adjust the stack pointer down 16 bytes and
// put our return address and frame pointer on the VM stack.
// Then set the VM's IP to new EBC code.
//
VmPtr->Gpr[0] -= 8;
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);
- VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];
- VmPtr->Gpr[0] -= 8;
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], (UINTN)FramePtr);
+ VmPtr->FramePtr = (VOID *)(UINTN)VmPtr->Gpr[0];
+ VmPtr->Gpr[0] -= 8;
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], (UINT64)(UINTN)(VmPtr->Ip + Size));
- VmPtr->Ip = (VMIP) InstructionBuffer->EbcEntryPoint;
+ VmPtr->Ip = (VMIP)InstructionBuffer->EbcEntryPoint;
} else {
//
// The callee is not a thunk to EBC, call native code,
@@ -472,4 +479,3 @@ EbcLLCALLEX ( VmPtr->Ip += Size;
}
}
-
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c index 966dfb7173..98ddf8c668 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c @@ -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;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c index e417f4870f..c0d5485cbf 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.c @@ -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;
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.h index 34253b3a1d..66624221dd 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/Edb.h @@ -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"
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBranch.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBranch.c index 500bb41da0..eb9f3db4f9 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBranch.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBranch.c @@ -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;
-
- ShowParameter = FALSE;
+ INTN Index;
+ UINTN SubIndex;
+ CHAR8 *FuncName;
+ EFI_DEBUGGER_CALLSTACK_CONTEXT *CallStackEntry;
+ BOOLEAN ShowParameter;
+ UINTN ParameterNumber;
+
+ 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",
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreak.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreak.c index 696703c4bb..7d0b6f1a82 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreak.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreak.c @@ -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
)
{
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c index 5d32c68406..791fd7d441 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c @@ -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");
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtIo.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtIo.c index d5390d13aa..6540f301cb 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtIo.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtIo.c @@ -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");
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtPci.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtPci.c index 93e8b503e3..49c57f66a4 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtPci.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdExtPci.c @@ -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");
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdGo.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdGo.c index e5cf857a2a..d51e627865 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdGo.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdGo.c @@ -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;
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdHelp.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdHelp.c index 74e1befee5..655384c34f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdHelp.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdHelp.c @@ -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;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c index 42bd8093f8..f0e0d9802f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdMemory.c @@ -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);
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdQuit.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdQuit.c index 76daf85402..98ad31acdd 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdQuit.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdQuit.c @@ -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;
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdRegister.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdRegister.c index 2ced0e4dd4..272e4556e5 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdRegister.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdRegister.c @@ -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);
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdScope.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdScope.c index 8240ab6242..d09bb8a781 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdScope.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdScope.c @@ -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);
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdStep.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdStep.c index 441f536764..3c5ef84965 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdStep.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdStep.c @@ -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
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c index 7b453fa98c..1b30b917f1 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdSymbol.c @@ -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) {
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c index 5597a7e154..e099b16986 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c @@ -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
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.h index ac8c23adfa..071d5c59b7 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.h @@ -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
);
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h index 924a2f7556..c5424948e3 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommon.h @@ -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_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_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)
//
// 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
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.c index 7d933cae76..18f16d7329 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.c @@ -44,7 +44,7 @@ EDB_DISASM_DEFINE (EdbDisasmMOVREL); //
// Debugger Disasm Table
//
-EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[] = {
+EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[] = {
EdbDisasmBREAK, // opcode 0x00 BREAK
EdbDisasmJMP, // opcode 0x01 JMP
EdbDisasmJMP8, // opcode 0x02 JMP8
@@ -118,12 +118,12 @@ EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[] = { **/
UINTN
EdbDisasmBREAK (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_BREAK);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_BREAK);
if (*(UINT8 *)(UINTN)(InstructionAddress + 1) > 6) {
return 0;
@@ -144,7 +144,7 @@ EdbDisasmBREAK ( return 2;
}
-extern CONST UINT8 mJMPLen[];
+extern CONST UINT8 mJMPLen[];
/**
@@ -159,9 +159,9 @@ extern CONST UINT8 mJMPLen[]; **/
UINTN
EdbDisasmJMP (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
UINT8 Modifiers;
@@ -170,11 +170,11 @@ EdbDisasmJMP ( UINT32 Data32;
UINT64 Data64;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_JMP);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_JMP);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Size = (UINTN)mJMPLen[(Modifiers >> 6) & 0x03];
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Size = (UINTN)mJMPLen[(Modifiers >> 6) & 0x03];
//
// Construct Disasm String
@@ -183,11 +183,11 @@ EdbDisasmJMP ( *DisasmString = EdbPreInstructionString ();
EdbPrintInstructionName (L"JMP");
-// if (Modifiers & OPCODE_M_IMMDATA64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+ // if (Modifiers & OPCODE_M_IMMDATA64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
if ((Modifiers & CONDITION_M_CONDITIONAL) != 0) {
if ((Modifiers & JMP_M_CS) != 0) {
EdbPrintInstructionName (L"cs");
@@ -198,20 +198,21 @@ EdbDisasmJMP ( InstructionAddress += 2;
if ((Modifiers & OPCODE_M_IMMDATA64) != 0) {
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
EdbPrintData64 (Data64);
} else {
return 0;
}
} else {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
EdbPrintRegister1 (Operands);
if ((Operands & OPERAND_M_INDIRECT1) == 0) {
if ((Modifiers & OPCODE_M_IMMDATA) == 0) {
Data32 = 0;
}
+
EdbPrintImmDatan (Data32);
} else {
EdbPrintRawIndexData32 (Data32);
@@ -237,15 +238,15 @@ EdbDisasmJMP ( **/
UINTN
EdbDisasmJMP8 (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
+ UINT8 Modifiers;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_JMP8);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_JMP8);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
//
// Construct Disasm String
@@ -283,26 +284,26 @@ EdbDisasmJMP8 ( **/
UINTN
EdbDisasmCALL (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT32 Data32;
- UINT64 Data64;
- UINT64 Ip;
- UINTN Result;
- EFI_PHYSICAL_ADDRESS SavedInstructionAddress;
-
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_CALL);
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT32 Data32;
+ UINT64 Data64;
+ UINT64 Ip;
+ UINTN Result;
+ EFI_PHYSICAL_ADDRESS SavedInstructionAddress;
+
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_CALL);
SavedInstructionAddress = InstructionAddress;
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Size = (UINTN)mJMPLen[(Modifiers >> 6) & 0x03];
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Size = (UINTN)mJMPLen[(Modifiers >> 6) & 0x03];
//
// Construct Disasm String
@@ -311,21 +312,22 @@ EdbDisasmCALL ( *DisasmString = EdbPreInstructionString ();
EdbPrintInstructionName (L"CALL");
-// if (Modifiers & OPCODE_M_IMMDATA64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+ // if (Modifiers & OPCODE_M_IMMDATA64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
if ((Operands & OPERAND_M_NATIVE_CALL) != 0) {
EdbPrintInstructionName (L"EX");
}
-// if ((Operands & OPERAND_M_RELATIVE_ADDR) == 0) {
-// EdbPrintInstructionName (L"a");
-// }
+
+ // if ((Operands & OPERAND_M_RELATIVE_ADDR) == 0) {
+ // EdbPrintInstructionName (L"a");
+ // }
InstructionAddress += 2;
if ((Modifiers & OPCODE_M_IMMDATA64) != 0) {
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
Ip = Data64;
if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
Result = EdbFindAndPrintSymbol ((UINTN)Ip);
@@ -337,7 +339,7 @@ EdbDisasmCALL ( }
} else {
if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
} else {
Data32 = 0;
}
@@ -354,6 +356,7 @@ EdbDisasmCALL ( } else {
Result = EdbFindAndPrintSymbol ((UINTN)Ip);
}
+
if (Result == 0) {
EdbPrintRegister1 (Operands);
if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
@@ -387,12 +390,12 @@ EdbDisasmCALL ( **/
UINTN
EdbDisasmRET (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_RET);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_RET);
if (*(UINT8 *)(UINTN)(InstructionAddress + 1) != 0) {
return 0;
@@ -425,28 +428,28 @@ EdbDisasmRET ( **/
UINTN
EdbDisasmCMP (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Opcode;
- UINT8 Modifiers;
- UINT8 Operands;
- UINT16 Data16;
- UINTN Size;
+ UINT8 Opcode;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINT16 Data16;
+ UINTN Size;
ASSERT (
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPEQ) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPLTE) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPGTE) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPULTE) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPUGTE)
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPEQ) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPLTE) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPGTE) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPULTE) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPUGTE)
);
- Opcode = GET_OPCODE (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
+ Opcode = GET_OPCODE (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -460,27 +463,27 @@ EdbDisasmCMP ( *DisasmString = EdbPreInstructionString ();
EdbPrintInstructionName (L"CMP");
-// if (Modifiers & OPCODE_M_64BIT) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+ // if (Modifiers & OPCODE_M_64BIT) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
switch (Opcode) {
- case OPCODE_CMPEQ:
- EdbPrintInstructionName (L"eq");
- break;
- case OPCODE_CMPLTE:
- EdbPrintInstructionName (L"lte");
- break;
- case OPCODE_CMPGTE:
- EdbPrintInstructionName (L"gte");
- break;
- case OPCODE_CMPULTE:
- EdbPrintInstructionName (L"ulte");
- break;
- case OPCODE_CMPUGTE:
- EdbPrintInstructionName (L"ugte");
- break;
+ case OPCODE_CMPEQ:
+ EdbPrintInstructionName (L"eq");
+ break;
+ case OPCODE_CMPLTE:
+ EdbPrintInstructionName (L"lte");
+ break;
+ case OPCODE_CMPGTE:
+ EdbPrintInstructionName (L"gte");
+ break;
+ case OPCODE_CMPULTE:
+ EdbPrintInstructionName (L"ulte");
+ break;
+ case OPCODE_CMPUGTE:
+ EdbPrintInstructionName (L"ugte");
+ break;
}
EdbPrintRegister1 (Operands);
@@ -490,7 +493,7 @@ EdbDisasmCMP ( EdbPrintRegister2 (Operands);
if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT2) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -517,35 +520,35 @@ EdbDisasmCMP ( **/
UINTN
EdbDisasmUnsignedDataManip (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Opcode;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Opcode;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
ASSERT (
- (GET_OPCODE(InstructionAddress) == OPCODE_NOT) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MULU) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_DIVU) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MODU) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_AND) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_OR) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_XOR) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_SHL) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_SHR) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_EXTNDB) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_EXTNDW) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_EXTNDD)
+ (GET_OPCODE (InstructionAddress) == OPCODE_NOT) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MULU) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_DIVU) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MODU) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_AND) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_OR) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_XOR) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_SHL) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_SHR) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_EXTNDB) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_EXTNDW) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_EXTNDD)
);
- Opcode = GET_OPCODE (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ Opcode = GET_OPCODE (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -559,48 +562,49 @@ EdbDisasmUnsignedDataManip ( *DisasmString = EdbPreInstructionString ();
switch (Opcode) {
- case OPCODE_NOT:
- EdbPrintInstructionName (L"NOT");
- break;
- case OPCODE_MULU:
- EdbPrintInstructionName (L"MULU");
- break;
- case OPCODE_DIVU:
- EdbPrintInstructionName (L"DIVU");
- break;
- case OPCODE_MODU:
- EdbPrintInstructionName (L"MODU");
- break;
- case OPCODE_AND:
- EdbPrintInstructionName (L"AND");
- break;
- case OPCODE_OR:
- EdbPrintInstructionName (L"OR");
- break;
- case OPCODE_XOR:
- EdbPrintInstructionName (L"XOR");
- break;
- case OPCODE_SHL:
- EdbPrintInstructionName (L"SHL");
- break;
- case OPCODE_SHR:
- EdbPrintInstructionName (L"SHR");
- break;
- case OPCODE_EXTNDB:
- EdbPrintInstructionName (L"EXTNDB");
- break;
- case OPCODE_EXTNDW:
- EdbPrintInstructionName (L"EXTNDW");
- break;
- case OPCODE_EXTNDD:
- EdbPrintInstructionName (L"EXTNDD");
- break;
+ case OPCODE_NOT:
+ EdbPrintInstructionName (L"NOT");
+ break;
+ case OPCODE_MULU:
+ EdbPrintInstructionName (L"MULU");
+ break;
+ case OPCODE_DIVU:
+ EdbPrintInstructionName (L"DIVU");
+ break;
+ case OPCODE_MODU:
+ EdbPrintInstructionName (L"MODU");
+ break;
+ case OPCODE_AND:
+ EdbPrintInstructionName (L"AND");
+ break;
+ case OPCODE_OR:
+ EdbPrintInstructionName (L"OR");
+ break;
+ case OPCODE_XOR:
+ EdbPrintInstructionName (L"XOR");
+ break;
+ case OPCODE_SHL:
+ EdbPrintInstructionName (L"SHL");
+ break;
+ case OPCODE_SHR:
+ EdbPrintInstructionName (L"SHR");
+ break;
+ case OPCODE_EXTNDB:
+ EdbPrintInstructionName (L"EXTNDB");
+ break;
+ case OPCODE_EXTNDW:
+ EdbPrintInstructionName (L"EXTNDW");
+ break;
+ case OPCODE_EXTNDD:
+ EdbPrintInstructionName (L"EXTNDD");
+ break;
}
-// if (Modifiers & DATAMANIP_M_64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+
+ // if (Modifiers & DATAMANIP_M_64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
EdbPrintRegister1 (Operands);
EdbPrintComma ();
@@ -608,7 +612,7 @@ EdbDisasmUnsignedDataManip ( InstructionAddress += 2;
if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT2) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -635,30 +639,30 @@ EdbDisasmUnsignedDataManip ( **/
UINTN
EdbDisasmSignedDataManip (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Opcode;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Opcode;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
ASSERT (
- (GET_OPCODE(InstructionAddress) == OPCODE_NEG) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_ADD) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_SUB) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MUL) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_DIV) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOD) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_ASHR)
+ (GET_OPCODE (InstructionAddress) == OPCODE_NEG) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_ADD) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_SUB) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MUL) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_DIV) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOD) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_ASHR)
);
- Opcode = GET_OPCODE (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ Opcode = GET_OPCODE (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -672,33 +676,34 @@ EdbDisasmSignedDataManip ( *DisasmString = EdbPreInstructionString ();
switch (Opcode) {
- case OPCODE_NEG:
- EdbPrintInstructionName (L"NEG");
- break;
- case OPCODE_ADD:
- EdbPrintInstructionName (L"ADD");
- break;
- case OPCODE_SUB:
- EdbPrintInstructionName (L"SUB");
- break;
- case OPCODE_MUL:
- EdbPrintInstructionName (L"MUL");
- break;
- case OPCODE_DIV:
- EdbPrintInstructionName (L"DIV");
- break;
- case OPCODE_MOD:
- EdbPrintInstructionName (L"MOD");
- break;
- case OPCODE_ASHR:
- EdbPrintInstructionName (L"ASHR");
- break;
+ case OPCODE_NEG:
+ EdbPrintInstructionName (L"NEG");
+ break;
+ case OPCODE_ADD:
+ EdbPrintInstructionName (L"ADD");
+ break;
+ case OPCODE_SUB:
+ EdbPrintInstructionName (L"SUB");
+ break;
+ case OPCODE_MUL:
+ EdbPrintInstructionName (L"MUL");
+ break;
+ case OPCODE_DIV:
+ EdbPrintInstructionName (L"DIV");
+ break;
+ case OPCODE_MOD:
+ EdbPrintInstructionName (L"MOD");
+ break;
+ case OPCODE_ASHR:
+ EdbPrintInstructionName (L"ASHR");
+ break;
}
-// if (Modifiers & DATAMANIP_M_64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+
+ // if (Modifiers & DATAMANIP_M_64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
EdbPrintRegister1 (Operands);
EdbPrintComma ();
@@ -706,7 +711,7 @@ EdbDisasmSignedDataManip ( InstructionAddress += 2;
if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT2) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -733,9 +738,9 @@ EdbDisasmSignedDataManip ( **/
UINTN
EdbDisasmMOVxx (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
UINT8 Modifiers;
@@ -747,28 +752,29 @@ EdbDisasmMOVxx ( UINT64 Data64;
ASSERT (
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVBW) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVWW) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVDW) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVQW) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVBD) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVWD) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVDD) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVQD) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVQQ) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVNW) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_MOVND)
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVBW) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVWW) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVDW) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVQW) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVBD) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVWD) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVDD) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVQD) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVQQ) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVNW) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_MOVND)
);
- Opcode = GET_OPCODE (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Size = 2;
+ Opcode = GET_OPCODE (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Size = 2;
if ((Modifiers & (OPCODE_M_IMMED_OP1 | OPCODE_M_IMMED_OP2)) != 0) {
if ((Opcode <= OPCODE_MOVQW) || (Opcode == OPCODE_MOVNW)) {
if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
Size += 2;
}
+
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
Size += 2;
}
@@ -776,6 +782,7 @@ EdbDisasmMOVxx ( if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
Size += 4;
}
+
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
Size += 4;
}
@@ -783,6 +790,7 @@ EdbDisasmMOVxx ( if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
Size += 8;
}
+
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
Size += 8;
}
@@ -797,39 +805,39 @@ EdbDisasmMOVxx ( EdbPrintInstructionName (L"MOV");
switch (Opcode) {
- case OPCODE_MOVBW:
- EdbPrintInstructionName (L"bw");
- break;
- case OPCODE_MOVWW:
- EdbPrintInstructionName (L"ww");
- break;
- case OPCODE_MOVDW:
- EdbPrintInstructionName (L"dw");
- break;
- case OPCODE_MOVQW:
- EdbPrintInstructionName (L"qw");
- break;
- case OPCODE_MOVBD:
- EdbPrintInstructionName (L"bd");
- break;
- case OPCODE_MOVWD:
- EdbPrintInstructionName (L"wd");
- break;
- case OPCODE_MOVDD:
- EdbPrintInstructionName (L"dd");
- break;
- case OPCODE_MOVQD:
- EdbPrintInstructionName (L"qd");
- break;
- case OPCODE_MOVQQ:
- EdbPrintInstructionName (L"qq");
- break;
- case OPCODE_MOVNW:
- EdbPrintInstructionName (L"nw");
- break;
- case OPCODE_MOVND:
- EdbPrintInstructionName (L"nd");
- break;
+ case OPCODE_MOVBW:
+ EdbPrintInstructionName (L"bw");
+ break;
+ case OPCODE_MOVWW:
+ EdbPrintInstructionName (L"ww");
+ break;
+ case OPCODE_MOVDW:
+ EdbPrintInstructionName (L"dw");
+ break;
+ case OPCODE_MOVQW:
+ EdbPrintInstructionName (L"qw");
+ break;
+ case OPCODE_MOVBD:
+ EdbPrintInstructionName (L"bd");
+ break;
+ case OPCODE_MOVWD:
+ EdbPrintInstructionName (L"wd");
+ break;
+ case OPCODE_MOVDD:
+ EdbPrintInstructionName (L"dd");
+ break;
+ case OPCODE_MOVQD:
+ EdbPrintInstructionName (L"qd");
+ break;
+ case OPCODE_MOVQQ:
+ EdbPrintInstructionName (L"qq");
+ break;
+ case OPCODE_MOVNW:
+ EdbPrintInstructionName (L"nw");
+ break;
+ case OPCODE_MOVND:
+ EdbPrintInstructionName (L"nd");
+ break;
}
EdbPrintRegister1 (Operands);
@@ -837,15 +845,15 @@ EdbDisasmMOVxx ( InstructionAddress += 2;
if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
if ((Opcode <= OPCODE_MOVQW) || (Opcode == OPCODE_MOVNW)) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
InstructionAddress += 2;
EdbPrintRawIndexData16 (Data16);
} else if ((Opcode <= OPCODE_MOVQD) || (Opcode == OPCODE_MOVND)) {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
InstructionAddress += 4;
EdbPrintRawIndexData32 (Data32);
} else if (Opcode == OPCODE_MOVQQ) {
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
InstructionAddress += 8;
EdbPrintRawIndexData64 (Data64);
}
@@ -856,13 +864,13 @@ EdbDisasmMOVxx ( if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
if ((Opcode <= OPCODE_MOVQW) || (Opcode == OPCODE_MOVNW)) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
EdbPrintRawIndexData16 (Data16);
} else if ((Opcode <= OPCODE_MOVQD) || (Opcode == OPCODE_MOVND)) {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
EdbPrintRawIndexData32 (Data32);
} else if (Opcode == OPCODE_MOVQQ) {
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
EdbPrintRawIndexData64 (Data64);
}
}
@@ -886,24 +894,25 @@ EdbDisasmMOVxx ( **/
UINTN
EdbDisasmMOVsnw (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_MOVSNW);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVSNW);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Size = 2;
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Size = 2;
if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
Size += 2;
}
+
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
Size += 2;
}
@@ -920,7 +929,7 @@ EdbDisasmMOVsnw ( InstructionAddress += 2;
if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
InstructionAddress += 2;
EdbPrintRawIndexData16 (Data16);
}
@@ -929,7 +938,7 @@ EdbDisasmMOVsnw ( EdbPrintRegister2 (Operands);
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT2) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -956,24 +965,25 @@ EdbDisasmMOVsnw ( **/
UINTN
EdbDisasmMOVsnd (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT32 Data32;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT32 Data32;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_MOVSND);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVSND);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
- Size = 2;
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Size = 2;
if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
Size += 4;
}
+
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
Size += 4;
}
@@ -990,7 +1000,7 @@ EdbDisasmMOVsnd ( InstructionAddress += 2;
if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
InstructionAddress += 4;
EdbPrintRawIndexData32 (Data32);
}
@@ -999,7 +1009,7 @@ EdbDisasmMOVsnd ( EdbPrintRegister2 (Operands);
if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
if ((Operands & OPERAND_M_INDIRECT2) != 0) {
EdbPrintRawIndexData32 (Data32);
} else {
@@ -1026,16 +1036,16 @@ EdbDisasmMOVsnd ( **/
UINTN
EdbDisasmLOADSP (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
UINT8 Operands;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_LOADSP);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_LOADSP);
- Operands = GET_OPERANDS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
//
// Construct Disasm String
@@ -1068,16 +1078,16 @@ EdbDisasmLOADSP ( **/
UINTN
EdbDisasmSTORESP (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
UINT8 Operands;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_STORESP);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_STORESP);
- Operands = GET_OPERANDS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
//
// Construct Disasm String
@@ -1097,7 +1107,6 @@ EdbDisasmSTORESP ( return 2;
}
-
/**
Disasm instruction - PUSH.
@@ -1111,20 +1120,20 @@ EdbDisasmSTORESP ( **/
UINTN
EdbDisasmPUSH (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_PUSH);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_PUSH);
- Operands = GET_OPERANDS (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -1138,17 +1147,17 @@ EdbDisasmPUSH ( *DisasmString = EdbPreInstructionString ();
EdbPrintInstructionName (L"PUSH");
-// if (Modifiers & PUSHPOP_M_64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+ // if (Modifiers & PUSHPOP_M_64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
EdbPrintRegister1 (Operands);
InstructionAddress += 2;
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT1) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -1175,20 +1184,20 @@ EdbDisasmPUSH ( **/
UINTN
EdbDisasmPOP (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_POP);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_POP);
- Operands = GET_OPERANDS (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -1202,17 +1211,17 @@ EdbDisasmPOP ( *DisasmString = EdbPreInstructionString ();
EdbPrintInstructionName (L"POP");
-// if (Modifiers & PUSHPOP_M_64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+ // if (Modifiers & PUSHPOP_M_64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
EdbPrintRegister1 (Operands);
InstructionAddress += 2;
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT1) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -1239,29 +1248,29 @@ EdbDisasmPOP ( **/
UINTN
EdbDisasmCMPI (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Opcode;
- UINT8 Operands;
- UINT16 Data16;
- UINT32 Data32;
- UINTN Size;
+ UINT8 Modifiers;
+ UINT8 Opcode;
+ UINT8 Operands;
+ UINT16 Data16;
+ UINT32 Data32;
+ UINTN Size;
ASSERT (
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPIEQ) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPILTE) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPIGTE) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPIULTE) ||
- (GET_OPCODE(InstructionAddress) == OPCODE_CMPIUGTE)
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPIEQ) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPILTE) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPIGTE) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPIULTE) ||
+ (GET_OPCODE (InstructionAddress) == OPCODE_CMPIUGTE)
);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Opcode = GET_OPCODE (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Opcode = GET_OPCODE (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
if ((Operands & 0xE0) != 0) {
return 0;
@@ -1271,6 +1280,7 @@ EdbDisasmCMPI ( if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
Size += 2;
}
+
if ((Modifiers & OPCODE_M_CMPI32_DATA) != 0) {
Size += 4;
} else {
@@ -1284,39 +1294,40 @@ EdbDisasmCMPI ( *DisasmString = EdbPreInstructionString ();
EdbPrintInstructionName (L"CMPI");
-// if (Modifiers & OPCODE_M_CMPI64) {
-// EdbPrintInstructionName (L"64");
-// } else {
-// EdbPrintInstructionName (L"32");
-// }
+ // if (Modifiers & OPCODE_M_CMPI64) {
+ // EdbPrintInstructionName (L"64");
+ // } else {
+ // EdbPrintInstructionName (L"32");
+ // }
if ((Modifiers & OPCODE_M_CMPI32_DATA) != 0) {
EdbPrintInstructionName (L"d");
} else {
EdbPrintInstructionName (L"w");
}
+
switch (Opcode) {
- case OPCODE_CMPIEQ:
- EdbPrintInstructionName (L"eq");
- break;
- case OPCODE_CMPILTE:
- EdbPrintInstructionName (L"lte");
- break;
- case OPCODE_CMPIGTE:
- EdbPrintInstructionName (L"gte");
- break;
- case OPCODE_CMPIULTE:
- EdbPrintInstructionName (L"ulte");
- break;
- case OPCODE_CMPIUGTE:
- EdbPrintInstructionName (L"ugte");
- break;
+ case OPCODE_CMPIEQ:
+ EdbPrintInstructionName (L"eq");
+ break;
+ case OPCODE_CMPILTE:
+ EdbPrintInstructionName (L"lte");
+ break;
+ case OPCODE_CMPIGTE:
+ EdbPrintInstructionName (L"gte");
+ break;
+ case OPCODE_CMPIULTE:
+ EdbPrintInstructionName (L"ulte");
+ break;
+ case OPCODE_CMPIUGTE:
+ EdbPrintInstructionName (L"ugte");
+ break;
}
EdbPrintRegister1 (Operands);
InstructionAddress += 2;
if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
InstructionAddress += 2;
EdbPrintRawIndexData16 (Data16);
}
@@ -1324,10 +1335,10 @@ EdbDisasmCMPI ( EdbPrintComma ();
if ((Modifiers & OPCODE_M_CMPI32_DATA) != 0) {
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
EdbPrintDatan (Data32);
} else {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
EdbPrintDatan (Data16);
}
@@ -1350,20 +1361,20 @@ EdbDisasmCMPI ( **/
UINTN
EdbDisasmPUSHn (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_PUSHN);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_PUSHN);
- Operands = GET_OPERANDS (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -1382,7 +1393,7 @@ EdbDisasmPUSHn ( InstructionAddress += 2;
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT1) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -1409,20 +1420,20 @@ EdbDisasmPUSHn ( **/
UINTN
EdbDisasmPOPn (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_POPN);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_POPN);
- Operands = GET_OPERANDS (InstructionAddress);
- Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
Size = 4;
} else {
@@ -1441,7 +1452,7 @@ EdbDisasmPOPn ( InstructionAddress += 2;
if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
if ((Operands & OPERAND_M_INDIRECT1) != 0) {
EdbPrintRawIndexData16 (Data16);
} else {
@@ -1468,28 +1479,29 @@ EdbDisasmPOPn ( **/
UINTN
EdbDisasmMOVI (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
- UINT32 Data32;
- UINT64 Data64;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
+ UINT32 Data32;
+ UINT64 Data64;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_MOVI);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVI);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
if ((Operands & MOVI_M_IMMDATA) != 0) {
- Size = 4;
+ Size = 4;
} else {
- Size = 2;
+ Size = 2;
}
+
if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
Size += 2;
} else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
@@ -1506,36 +1518,37 @@ EdbDisasmMOVI ( EdbPrintInstructionName (L"MOVI");
switch (Operands & MOVI_M_MOVEWIDTH) {
- case MOVI_MOVEWIDTH8:
- EdbPrintInstructionName (L"b");
- break;
- case MOVI_MOVEWIDTH16:
- EdbPrintInstructionName (L"w");
- break;
- case MOVI_MOVEWIDTH32:
- EdbPrintInstructionName (L"d");
- break;
- case MOVI_MOVEWIDTH64:
- EdbPrintInstructionName (L"q");
- break;
+ case MOVI_MOVEWIDTH8:
+ EdbPrintInstructionName (L"b");
+ break;
+ case MOVI_MOVEWIDTH16:
+ EdbPrintInstructionName (L"w");
+ break;
+ case MOVI_MOVEWIDTH32:
+ EdbPrintInstructionName (L"d");
+ break;
+ case MOVI_MOVEWIDTH64:
+ EdbPrintInstructionName (L"q");
+ break;
}
+
switch (Modifiers & MOVI_M_DATAWIDTH) {
- case MOVI_DATAWIDTH16:
- EdbPrintInstructionName (L"w");
- break;
- case MOVI_DATAWIDTH32:
- EdbPrintInstructionName (L"d");
- break;
- case MOVI_DATAWIDTH64:
- EdbPrintInstructionName (L"q");
- break;
+ case MOVI_DATAWIDTH16:
+ EdbPrintInstructionName (L"w");
+ break;
+ case MOVI_DATAWIDTH32:
+ EdbPrintInstructionName (L"d");
+ break;
+ case MOVI_DATAWIDTH64:
+ EdbPrintInstructionName (L"q");
+ break;
}
EdbPrintRegister1 (Operands);
InstructionAddress += 2;
if ((Operands & MOVI_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
InstructionAddress += 2;
EdbPrintRawIndexData16 (Data16);
}
@@ -1543,18 +1556,18 @@ EdbDisasmMOVI ( EdbPrintComma ();
switch (Modifiers & MOVI_M_DATAWIDTH) {
- case MOVI_DATAWIDTH16:
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
- EdbPrintDatan (Data16);
- break;
- case MOVI_DATAWIDTH32:
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
- EdbPrintDatan (Data32);
- break;
- case MOVI_DATAWIDTH64:
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
- EdbPrintData64n (Data64);
- break;
+ case MOVI_DATAWIDTH16:
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
+ EdbPrintDatan (Data16);
+ break;
+ case MOVI_DATAWIDTH32:
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
+ EdbPrintDatan (Data32);
+ break;
+ case MOVI_DATAWIDTH64:
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
+ EdbPrintData64n (Data64);
+ break;
}
EdbPostInstructionString ();
@@ -1576,28 +1589,29 @@ EdbDisasmMOVI ( **/
UINTN
EdbDisasmMOVIn (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
- UINT32 Data32;
- UINT64 Data64;
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
+ UINT32 Data32;
+ UINT64 Data64;
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_MOVIN);
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVIN);
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
if ((Operands & MOVI_M_IMMDATA) != 0) {
- Size = 4;
+ Size = 4;
} else {
- Size = 2;
+ Size = 2;
}
+
if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
Size += 2;
} else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
@@ -1614,22 +1628,22 @@ EdbDisasmMOVIn ( EdbPrintInstructionName (L"MOVIn");
switch (Modifiers & MOVI_M_DATAWIDTH) {
- case MOVI_DATAWIDTH16:
- EdbPrintInstructionName (L"w");
- break;
- case MOVI_DATAWIDTH32:
- EdbPrintInstructionName (L"d");
- break;
- case MOVI_DATAWIDTH64:
- EdbPrintInstructionName (L"q");
- break;
+ case MOVI_DATAWIDTH16:
+ EdbPrintInstructionName (L"w");
+ break;
+ case MOVI_DATAWIDTH32:
+ EdbPrintInstructionName (L"d");
+ break;
+ case MOVI_DATAWIDTH64:
+ EdbPrintInstructionName (L"q");
+ break;
}
EdbPrintRegister1 (Operands);
InstructionAddress += 2;
if ((Operands & MOVI_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
InstructionAddress += 2;
EdbPrintRawIndexData16 (Data16);
}
@@ -1637,18 +1651,18 @@ EdbDisasmMOVIn ( EdbPrintComma ();
switch (Modifiers & MOVI_M_DATAWIDTH) {
- case MOVI_DATAWIDTH16:
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
- EdbPrintRawIndexData16 (Data16);
- break;
- case MOVI_DATAWIDTH32:
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
- EdbPrintRawIndexData32 (Data32);
- break;
- case MOVI_DATAWIDTH64:
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
- EdbPrintRawIndexData64 (Data64);
- break;
+ case MOVI_DATAWIDTH16:
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
+ EdbPrintRawIndexData16 (Data16);
+ break;
+ case MOVI_DATAWIDTH32:
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
+ EdbPrintRawIndexData32 (Data32);
+ break;
+ case MOVI_DATAWIDTH64:
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
+ EdbPrintRawIndexData64 (Data64);
+ break;
}
EdbPostInstructionString ();
@@ -1670,31 +1684,32 @@ EdbDisasmMOVIn ( **/
UINTN
EdbDisasmMOVREL (
- IN EFI_PHYSICAL_ADDRESS InstructionAddress,
- IN EFI_SYSTEM_CONTEXT SystemContext,
- OUT CHAR16 **DisasmString
+ IN EFI_PHYSICAL_ADDRESS InstructionAddress,
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ OUT CHAR16 **DisasmString
)
{
- UINT8 Modifiers;
- UINT8 Operands;
- UINTN Size;
- UINT16 Data16;
- UINT32 Data32;
- UINT64 Data64;
- UINTN Result;
- EFI_PHYSICAL_ADDRESS SavedInstructionAddress;
-
- ASSERT (GET_OPCODE(InstructionAddress) == OPCODE_MOVREL);
+ UINT8 Modifiers;
+ UINT8 Operands;
+ UINTN Size;
+ UINT16 Data16;
+ UINT32 Data32;
+ UINT64 Data64;
+ UINTN Result;
+ EFI_PHYSICAL_ADDRESS SavedInstructionAddress;
+
+ ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVREL);
SavedInstructionAddress = InstructionAddress;
- Modifiers = GET_MODIFIERS (InstructionAddress);
- Operands = GET_OPERANDS (InstructionAddress);
+ Modifiers = GET_MODIFIERS (InstructionAddress);
+ Operands = GET_OPERANDS (InstructionAddress);
if ((Operands & MOVI_M_IMMDATA) != 0) {
- Size = 4;
+ Size = 4;
} else {
- Size = 2;
+ Size = 2;
}
+
if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
Size += 2;
} else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
@@ -1713,22 +1728,22 @@ EdbDisasmMOVREL ( EdbPrintInstructionName (L"MOVrel");
switch (Modifiers & MOVI_M_DATAWIDTH) {
- case MOVI_DATAWIDTH16:
- EdbPrintInstructionName (L"w");
- break;
- case MOVI_DATAWIDTH32:
- EdbPrintInstructionName (L"d");
- break;
- case MOVI_DATAWIDTH64:
- EdbPrintInstructionName (L"q");
- break;
+ case MOVI_DATAWIDTH16:
+ EdbPrintInstructionName (L"w");
+ break;
+ case MOVI_DATAWIDTH32:
+ EdbPrintInstructionName (L"d");
+ break;
+ case MOVI_DATAWIDTH64:
+ EdbPrintInstructionName (L"q");
+ break;
}
EdbPrintRegister1 (Operands);
InstructionAddress += 2;
if ((Operands & MOVI_M_IMMDATA) != 0) {
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
InstructionAddress += 2;
EdbPrintRawIndexData16 (Data16);
}
@@ -1736,31 +1751,35 @@ EdbDisasmMOVREL ( EdbPrintComma ();
switch (Modifiers & MOVI_M_DATAWIDTH) {
- case MOVI_DATAWIDTH16:
- CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT16));
- Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT16)Data16));
- if (Result == 0) {
- EdbPrintData16 (Data16);
- }
- break;
- case MOVI_DATAWIDTH32:
- CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT32));
- Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT32)Data32));
- if (Result == 0) {
- EdbPrintData32 (Data32);
- }
- break;
- case MOVI_DATAWIDTH64:
- CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof(UINT64));
- if (sizeof(UINTN) == sizeof(UINT64)) {
- Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT64)Data64));
- } else {
- Result = 0;
- }
- if (Result == 0) {
- EdbPrintData64 (Data64);
- }
- break;
+ case MOVI_DATAWIDTH16:
+ CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
+ Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT16)Data16));
+ if (Result == 0) {
+ EdbPrintData16 (Data16);
+ }
+
+ break;
+ case MOVI_DATAWIDTH32:
+ CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
+ Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT32)Data32));
+ if (Result == 0) {
+ EdbPrintData32 (Data32);
+ }
+
+ break;
+ case MOVI_DATAWIDTH64:
+ CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
+ if (sizeof (UINTN) == sizeof (UINT64)) {
+ Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT64)Data64));
+ } else {
+ Result = 0;
+ }
+
+ if (Result == 0) {
+ EdbPrintData64 (Data64);
+ }
+
+ break;
}
EdbPostInstructionString ();
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.h index 43fa5f4b8b..e2617581fc 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasm.h @@ -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
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.c index feb3fb121c..f43b891e2e 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.c @@ -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;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h index b1e7a468ee..7542b5c2c7 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h @@ -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
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c index 1bfe5240c7..4a04e902fb 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c @@ -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;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h index ba8b936b3a..43f750440f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h @@ -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
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportFile.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportFile.c index ee2f8fc2f2..cef5141423 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportFile.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportFile.c @@ -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++;
}
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c index 9679a23002..e450e57662 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c @@ -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;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c index dd881a0212..9844cf8505 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c @@ -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_BACKSPACE:
- if (StrPos != 0) {
- //
- // If not move back beyond string beginning, move all characters behind
- // the current position one character forward
+ case CHAR_CARRIAGE_RETURN:
//
- StrPos -= 1;
- Update = StrPos;
- Delete = 1;
- CopyMem (InStr + StrPos, InStr + StrPos + 1, sizeof (CHAR16) * (Len - StrPos));
-
+ // All done, print a newline at the end of the string
//
- // 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;
+ TailRow = Row + (Len - StrPos + Column) / LineLength;
+ TailColumn = (Len - StrPos + Column) % LineLength;
+ Done = TRUE;
+ 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));
- NeedAdjust = TRUE;
- }
- break;
-
- case SCAN_LEFT:
- //
- // Adjust current cursor position
- //
- if (StrPos != 0) {
- StrPos -= 1;
+ //
+ // Adjust the current column and row
+ //
ConMoveCursorBackward (LineLength, &Column, &Row);
- }
- break;
- case SCAN_RIGHT:
- //
- // Adjust current cursor position
- //
- if (StrPos < Len) {
- StrPos += 1;
- ConMoveCursorForward (LineLength, TotalRow, &Column, &Row);
+ NeedAdjust = TRUE;
}
- 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;
+ default:
+ if (Key.UnicodeChar >= ' ') {
+ //
+ // If we are at the buffer's end, drop the key
+ //
+ if ((Len == StrLength - 1) && (InsertMode || (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;
+ //
+ // 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];
+ }
+ }
- case SCAN_INSERT:
- //
- // Toggle the SEnvInsertMode flag
- //
- InsertMode = (BOOLEAN)!InsertMode;
- break;
+ InStr[StrPos] = Key.UnicodeChar;
+ Update = StrPos;
- 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' ';
+ StrPos += 1;
+ OutputLength = 1;
}
- 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 ;
+ 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;
- }
}
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;
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c index 90a9b9fbd7..834c90e32a 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c @@ -48,7 +48,7 @@ EdbLoadSymbolSingleEntry ( //
// Print Debug info
//
- if (sizeof (UINTN) == sizeof(UINT64)) {
+ if (sizeof (UINTN) == sizeof (UINT64)) {
DEBUG ((DEBUG_ERROR, " Symbol: %a, Address: 0x%016lx (%d)\n", Name, (UINT64)Address, (UINTN)Type));
} else {
DEBUG ((DEBUG_ERROR, " Symbol: %a, Address: 0x%08x (%d)\n", Name, Address, (UINTN)Type));
@@ -57,11 +57,12 @@ EdbLoadSymbolSingleEntry ( //
// Fill the entry - name, RVA, type
//
- AsciiStrnCpyS (Entry->Name, sizeof(Entry->Name), Name, sizeof(Entry->Name) - 1);
+ AsciiStrnCpyS (Entry->Name, sizeof (Entry->Name), Name, sizeof (Entry->Name) - 1);
if (ObjName != NULL) {
- AsciiStrnCpyS (Entry->ObjName, sizeof(Entry->ObjName), ObjName, sizeof(Entry->ObjName) - 1);
+ AsciiStrnCpyS (Entry->ObjName, sizeof (Entry->ObjName), ObjName, sizeof (Entry->ObjName) - 1);
}
- Entry->Rva = Address % EFI_DEBUGGER_DEFAULT_LINK_IMAGEBASE;
+
+ Entry->Rva = Address % EFI_DEBUGGER_DEFAULT_LINK_IMAGEBASE;
Entry->Type = Type;
//
@@ -167,34 +168,33 @@ EdbLoadSymbolEntryByIec ( IN VOID *Buffer
)
{
- CHAR8 *LineBuffer;
- CHAR8 *FieldBuffer;
- EDB_EBC_MAP_PARSE_STATE MapParseState;
- EDB_EBC_SYMBOL_PARSE_STATE SymbolParseState;
- CHAR8 *Name;
- CHAR8 *ObjName;
- UINTN Address;
- EFI_DEBUGGER_SYMBOL_TYPE Type;
-
+ CHAR8 *LineBuffer;
+ CHAR8 *FieldBuffer;
+ EDB_EBC_MAP_PARSE_STATE MapParseState;
+ EDB_EBC_SYMBOL_PARSE_STATE SymbolParseState;
+ CHAR8 *Name;
+ CHAR8 *ObjName;
+ UINTN Address;
+ EFI_DEBUGGER_SYMBOL_TYPE Type;
//
// Begin to parse the Buffer
//
- LineBuffer = AsciiStrGetNewTokenLine (Buffer, "\n\r");
+ LineBuffer = AsciiStrGetNewTokenLine (Buffer, "\n\r");
MapParseState = EdbEbcMapParseStateUninitialized;
//
// Check each line
//
while (LineBuffer != NULL) {
- FieldBuffer = AsciiStrGetNewTokenField (LineBuffer, " ");
+ FieldBuffer = AsciiStrGetNewTokenField (LineBuffer, " ");
SymbolParseState = EdbEbcSymbolParseStateUninitialized;
//
// Init entry value
//
- Name = NULL;
+ Name = NULL;
ObjName = NULL;
Address = 0;
- Type = EfiDebuggerSymbolTypeMax;
+ Type = EfiDebuggerSymbolTypeMax;
//
// Check each field
//
@@ -203,6 +203,7 @@ EdbLoadSymbolEntryByIec ( FieldBuffer = AsciiStrGetNextTokenField (" ");
continue;
}
+
//
// check "Address"
//
@@ -210,6 +211,7 @@ EdbLoadSymbolEntryByIec ( MapParseState = EdbEbcMapParseStateSymbolStart;
break;
}
+
//
// check "Static"
//
@@ -224,6 +226,7 @@ EdbLoadSymbolEntryByIec ( //
break;
}
+
if (AsciiStrCmp (FieldBuffer, "entry") == 0) {
//
// Skip entry point
@@ -235,126 +238,132 @@ EdbLoadSymbolEntryByIec ( // Now we start to parse this line for Name, Address, and Object
//
switch (SymbolParseState) {
- case EdbEbcSymbolParseStateUninitialized:
- //
- // Get the Address
- //
- SymbolParseState = EdbEbcSymbolParseStateReadyForName;
- break;
- case EdbEbcSymbolParseStateReadyForName:
- //
- // Get the Name
- //
- if (AsciiStrnCmp (FieldBuffer, "___safe_se_handler", AsciiStrLen ("___safe_se_handler")) == 0) {
+ case EdbEbcSymbolParseStateUninitialized:
//
- // skip SeHandler
+ // Get the Address
//
- MapParseState = EdbEbcMapParseStateSeHandlerSymbol;
- goto ExitFieldParse;
- } else if (AsciiStrnCmp (FieldBuffer, "varbss_init", AsciiStrLen ("varbss_init")) == 0) {
+ SymbolParseState = EdbEbcSymbolParseStateReadyForName;
+ break;
+ case EdbEbcSymbolParseStateReadyForName:
//
- // check VarbssInit
+ // Get the Name
//
- MapParseState = EdbEbcMapParseStateVarbssInitSymbol;
-// goto ExitFieldParse;
- Name = FieldBuffer;
- SymbolParseState = EdbEbcSymbolParseStateReadyForRVA;
- } else if (AsciiStrnCmp (FieldBuffer, "Crt", AsciiStrLen ("Crt")) == 0) {
+ if (AsciiStrnCmp (FieldBuffer, "___safe_se_handler", AsciiStrLen ("___safe_se_handler")) == 0) {
+ //
+ // skip SeHandler
+ //
+ MapParseState = EdbEbcMapParseStateSeHandlerSymbol;
+ goto ExitFieldParse;
+ } else if (AsciiStrnCmp (FieldBuffer, "varbss_init", AsciiStrLen ("varbss_init")) == 0) {
+ //
+ // check VarbssInit
+ //
+ MapParseState = EdbEbcMapParseStateVarbssInitSymbol;
+ // goto ExitFieldParse;
+ Name = FieldBuffer;
+ SymbolParseState = EdbEbcSymbolParseStateReadyForRVA;
+ } else if (AsciiStrnCmp (FieldBuffer, "Crt", AsciiStrLen ("Crt")) == 0) {
+ //
+ // check Crt
+ //
+ MapParseState = EdbEbcMapParseStateCrtSymbol;
+ // goto ExitFieldParse;
+ Name = FieldBuffer;
+ SymbolParseState = EdbEbcSymbolParseStateReadyForRVA;
+ } else {
+ //
+ // Now, it is normal function
+ //
+ switch (MapParseState) {
+ case EdbEbcMapParseStateSeHandlerSymbol:
+ MapParseState = EdbEbcMapParseStateFunctionSymbol;
+ break;
+ case EdbEbcMapParseStateCrtSymbol:
+ MapParseState = EdbEbcMapParseStateVariableSymbol;
+ break;
+ case EdbEbcMapParseStateFunctionSymbol:
+ case EdbEbcMapParseStateVariableSymbol:
+ case EdbEbcMapParseStateStaticFunctionSymbol:
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+
+ Name = FieldBuffer;
+ SymbolParseState = EdbEbcSymbolParseStateReadyForRVA;
+ }
+
+ break;
+ case EdbEbcSymbolParseStateReadyForRVA:
//
- // check Crt
+ // Get the RVA
//
- MapParseState = EdbEbcMapParseStateCrtSymbol;
-// goto ExitFieldParse;
- Name = FieldBuffer;
- SymbolParseState = EdbEbcSymbolParseStateReadyForRVA;
- } else {
+ Address = AsciiXtoi (FieldBuffer);
+ SymbolParseState = EdbEbcSymbolParseStateReadyForType;
+ break;
+ case EdbEbcSymbolParseStateReadyForType:
//
- // Now, it is normal function
+ // Get the Type. This is optional, only for "f".
//
- switch (MapParseState) {
- case EdbEbcMapParseStateSeHandlerSymbol:
- MapParseState = EdbEbcMapParseStateFunctionSymbol;
- break;
- case EdbEbcMapParseStateCrtSymbol:
- MapParseState = EdbEbcMapParseStateVariableSymbol;
- break;
- case EdbEbcMapParseStateFunctionSymbol:
- case EdbEbcMapParseStateVariableSymbol:
- case EdbEbcMapParseStateStaticFunctionSymbol:
- break;
- default:
- ASSERT (FALSE);
- break;
- }
- Name = FieldBuffer;
- SymbolParseState = EdbEbcSymbolParseStateReadyForRVA;
- }
- break;
- case EdbEbcSymbolParseStateReadyForRVA:
- //
- // Get the RVA
- //
- Address = AsciiXtoi (FieldBuffer);
- SymbolParseState = EdbEbcSymbolParseStateReadyForType;
- break;
- case EdbEbcSymbolParseStateReadyForType:
- //
- // Get the Type. This is optional, only for "f".
- //
- if (AsciiStrCmp (FieldBuffer, "f") == 0) {
- SymbolParseState = EdbEbcSymbolParseStateReadyForObject;
- switch (MapParseState) {
- case EdbEbcMapParseStateFunctionSymbol:
- case EdbEbcMapParseStateVarbssInitSymbol:
- Type = EfiDebuggerSymbolFunction;
- break;
- case EdbEbcMapParseStateStaticFunctionSymbol:
- Type = EfiDebuggerSymbolStaticFunction;
- break;
- default:
- ASSERT (FALSE);
+ if (AsciiStrCmp (FieldBuffer, "f") == 0) {
+ SymbolParseState = EdbEbcSymbolParseStateReadyForObject;
+ switch (MapParseState) {
+ case EdbEbcMapParseStateFunctionSymbol:
+ case EdbEbcMapParseStateVarbssInitSymbol:
+ Type = EfiDebuggerSymbolFunction;
+ break;
+ case EdbEbcMapParseStateStaticFunctionSymbol:
+ Type = EfiDebuggerSymbolStaticFunction;
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+
break;
}
- break;
- }
+
//
// Else it should be Object.
// let it bypass here
//
- case EdbEbcSymbolParseStateReadyForObject:
- switch (Type) {
- case EfiDebuggerSymbolTypeMax:
- switch (MapParseState) {
- case EdbEbcMapParseStateVariableSymbol:
- case EdbEbcMapParseStateCrtSymbol:
- Type = EfiDebuggerSymbolGlobalVariable;
- break;
- case EdbEbcMapParseStateSeHandlerSymbol:
- //
- // do nothing here
- //
- break;
- default:
- ASSERT (FALSE);
- break;
+ case EdbEbcSymbolParseStateReadyForObject:
+ switch (Type) {
+ case EfiDebuggerSymbolTypeMax:
+ switch (MapParseState) {
+ case EdbEbcMapParseStateVariableSymbol:
+ case EdbEbcMapParseStateCrtSymbol:
+ Type = EfiDebuggerSymbolGlobalVariable;
+ break;
+ case EdbEbcMapParseStateSeHandlerSymbol:
+ //
+ // do nothing here
+ //
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+
+ break;
+ case EfiDebuggerSymbolFunction:
+ case EfiDebuggerSymbolStaticFunction:
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
}
- break;
- case EfiDebuggerSymbolFunction:
- case EfiDebuggerSymbolStaticFunction:
+
+ //
+ // Get the Object
+ //
+ ObjName = FieldBuffer;
+ SymbolParseState = EdbEbcSymbolParseStateUninitialized;
break;
default:
ASSERT (FALSE);
break;
- }
- //
- // Get the Object
- //
- ObjName = FieldBuffer;
- SymbolParseState = EdbEbcSymbolParseStateUninitialized;
- break;
- default:
- ASSERT (FALSE);
- break;
}
//
@@ -423,12 +432,12 @@ EdbLoadSymbolEntry ( **/
EFI_DEBUGGER_SYMBOL_OBJECT *
EdbFindSymbolFile (
- IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
- IN CHAR16 *FileName,
- IN OUT UINTN *Index OPTIONAL
+ IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
+ IN CHAR16 *FileName,
+ IN OUT UINTN *Index OPTIONAL
)
{
- UINTN ObjectIndex;
+ UINTN ObjectIndex;
//
// Check each Object
@@ -441,6 +450,7 @@ EdbFindSymbolFile ( if (Index != NULL) {
*Index = ObjectIndex;
}
+
return &DebuggerPrivate->DebuggerSymbolContext.Object[ObjectIndex];
}
}
@@ -465,22 +475,22 @@ EdbFindSymbolFile ( **/
UINTN
EbdFindSymbolAddress (
- IN UINTN Address,
- IN EDB_MATCH_SYMBOL_TYPE Type,
- OUT EFI_DEBUGGER_SYMBOL_OBJECT **RetObject,
- OUT EFI_DEBUGGER_SYMBOL_ENTRY **RetEntry
+ IN UINTN Address,
+ IN EDB_MATCH_SYMBOL_TYPE Type,
+ OUT EFI_DEBUGGER_SYMBOL_OBJECT **RetObject,
+ OUT EFI_DEBUGGER_SYMBOL_ENTRY **RetEntry
)
{
- UINTN Index;
- UINTN SubIndex;
- UINTN CandidateLowerAddress;
- UINTN CandidateUpperAddress;
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
- EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
- EFI_DEBUGGER_SYMBOL_ENTRY *LowEntry;
- EFI_DEBUGGER_SYMBOL_ENTRY *UpperEntry;
- EFI_DEBUGGER_SYMBOL_OBJECT *LowObject;
- EFI_DEBUGGER_SYMBOL_OBJECT *UpperObject;
+ UINTN Index;
+ UINTN SubIndex;
+ UINTN CandidateLowerAddress;
+ UINTN CandidateUpperAddress;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ EFI_DEBUGGER_SYMBOL_ENTRY *Entry;
+ EFI_DEBUGGER_SYMBOL_ENTRY *LowEntry;
+ EFI_DEBUGGER_SYMBOL_ENTRY *UpperEntry;
+ EFI_DEBUGGER_SYMBOL_OBJECT *LowObject;
+ EFI_DEBUGGER_SYMBOL_OBJECT *UpperObject;
if ((Type < 0) || (Type >= EdbMatchSymbolTypeMax)) {
return 0;
@@ -491,10 +501,10 @@ EbdFindSymbolAddress ( //
CandidateLowerAddress = 0;
CandidateUpperAddress = (UINTN)-1;
- LowEntry = NULL;
- UpperEntry = NULL;
- LowObject = NULL;
- UpperObject = NULL;
+ LowEntry = NULL;
+ UpperEntry = NULL;
+ LowObject = NULL;
+ UpperObject = NULL;
//
// Go through each object
@@ -504,6 +514,7 @@ EbdFindSymbolAddress ( if (Object->EntryCount == 0) {
continue;
}
+
//
// Go through each entry
//
@@ -519,8 +530,8 @@ EbdFindSymbolAddress ( //
if (CandidateLowerAddress < Entry->Rva + Object->BaseAddress) {
CandidateLowerAddress = Entry->Rva + Object->BaseAddress;
- LowEntry = Entry;
- LowObject = Object;
+ LowEntry = Entry;
+ LowObject = Object;
}
} else {
//
@@ -528,16 +539,18 @@ EbdFindSymbolAddress ( //
if (CandidateUpperAddress > Entry->Rva + Object->BaseAddress) {
CandidateUpperAddress = Entry->Rva + Object->BaseAddress;
- UpperEntry = Entry;
- UpperObject = Object;
+ UpperEntry = Entry;
+ UpperObject = Object;
}
}
+
continue;
}
+
//
// address match, return directly
//
- *RetEntry = Entry;
+ *RetEntry = Entry;
*RetObject = Object;
return Address;
}
@@ -553,11 +566,12 @@ EbdFindSymbolAddress ( //
if (((Type == EdbMatchSymbolTypeNearestAddress) &&
((CandidateUpperAddress - Address) > (Address - CandidateLowerAddress))) ||
- (Type == EdbMatchSymbolTypeLowerAddress)) {
+ (Type == EdbMatchSymbolTypeLowerAddress))
+ {
//
// return nearest lower address
//
- *RetEntry = LowEntry;
+ *RetEntry = LowEntry;
*RetObject = LowObject;
return CandidateLowerAddress;
}
@@ -569,11 +583,12 @@ EbdFindSymbolAddress ( //
if (((Type == EdbMatchSymbolTypeNearestAddress) &&
((CandidateUpperAddress - Address) < (Address - CandidateLowerAddress))) ||
- (Type == EdbMatchSymbolTypeUpperAddress)) {
+ (Type == EdbMatchSymbolTypeUpperAddress))
+ {
//
// return nearest upper address
//
- *RetEntry = UpperEntry;
+ *RetEntry = UpperEntry;
*RetObject = UpperObject;
return CandidateUpperAddress;
}
@@ -597,17 +612,17 @@ EbdFindSymbolAddress ( **/
EFI_STATUS
EdbUnloadSymbol (
- IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
- IN CHAR16 *FileName
+ IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
+ IN CHAR16 *FileName
)
{
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
- UINTN ObjectIndex;
- UINTN Index;
- EFI_DEBUGGER_SYMBOL_ENTRY *OldEntry;
- UINTN OldEntryCount;
- UINTN MaxEntryCount;
- VOID **OldSourceBuffer;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ UINTN ObjectIndex;
+ UINTN Index;
+ EFI_DEBUGGER_SYMBOL_ENTRY *OldEntry;
+ UINTN OldEntryCount;
+ UINTN MaxEntryCount;
+ VOID **OldSourceBuffer;
//
// Find Symbol
@@ -621,33 +636,34 @@ EdbUnloadSymbol ( //
// Record old data
//
- Object = DebuggerPrivate->DebuggerSymbolContext.Object;
- OldEntry = Object->Entry;
+ Object = DebuggerPrivate->DebuggerSymbolContext.Object;
+ OldEntry = Object->Entry;
OldSourceBuffer = Object->SourceBuffer;
- MaxEntryCount = Object->MaxEntryCount;
- OldEntryCount = Object->EntryCount;
+ MaxEntryCount = Object->MaxEntryCount;
+ OldEntryCount = Object->EntryCount;
//
// Remove the matched Object
//
for (Index = ObjectIndex; Index < DebuggerPrivate->DebuggerSymbolContext.ObjectCount - 1; Index++) {
- CopyMem (&Object[Index], &Object[Index + 1], sizeof(EFI_DEBUGGER_SYMBOL_OBJECT));
+ CopyMem (&Object[Index], &Object[Index + 1], sizeof (EFI_DEBUGGER_SYMBOL_OBJECT));
}
- ZeroMem (&Object[Index], sizeof(Object[Index]));
+
+ ZeroMem (&Object[Index], sizeof (Object[Index]));
//
// Move old data to new place
//
- Object[Index].Entry = OldEntry;
- Object[Index].SourceBuffer = OldSourceBuffer;
+ Object[Index].Entry = OldEntry;
+ Object[Index].SourceBuffer = OldSourceBuffer;
Object[Index].MaxEntryCount = MaxEntryCount;
- DebuggerPrivate->DebuggerSymbolContext.ObjectCount --;
+ DebuggerPrivate->DebuggerSymbolContext.ObjectCount--;
//
// Clean old entry data
//
for (Index = 0; Index < OldEntryCount; Index++) {
- ZeroMem (&OldEntry[Index], sizeof(OldEntry[Index]));
+ ZeroMem (&OldEntry[Index], sizeof (OldEntry[Index]));
}
//
@@ -675,14 +691,14 @@ EdbUnloadSymbol ( **/
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
)
{
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
- EFI_STATUS Status;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ EFI_STATUS Status;
//
// Check duplicated File
@@ -690,7 +706,7 @@ EdbLoadSymbol ( Object = EdbFindSymbolFile (DebuggerPrivate, FileName, NULL);
if (Object != NULL) {
Status = EdbUnloadSymbol (DebuggerPrivate, FileName);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Unload Duplicated Symbol File Error!\n"));
return Status;
}
@@ -712,7 +728,7 @@ EdbLoadSymbol ( //
// Init Object
//
- Object->EntryCount = 0;
+ Object->EntryCount = 0;
Object->MaxEntryCount = EFI_DEBUGGER_SYMBOL_ENTRY_MAX;
//
@@ -727,14 +743,18 @@ EdbLoadSymbol ( //
// Fill Object value
//
- StrnCpyS (Object->Name, sizeof(Object->Name) / sizeof(CHAR16),
- FileName, (sizeof(Object->Name) / sizeof(CHAR16)) - 1);
+ StrnCpyS (
+ Object->Name,
+ sizeof (Object->Name) / sizeof (CHAR16),
+ FileName,
+ (sizeof (Object->Name) / sizeof (CHAR16)) - 1
+ );
Object->BaseAddress = 0;
//
// Increase the object count
//
- DebuggerPrivate->DebuggerSymbolContext.ObjectCount ++;
+ DebuggerPrivate->DebuggerSymbolContext.ObjectCount++;
return EFI_SUCCESS;
}
@@ -751,25 +771,25 @@ EdbLoadSymbol ( **/
CHAR8 *
GetPdbPath (
- VOID *ImageBase
+ VOID *ImageBase
)
{
- CHAR8 *PdbPath;
- UINT32 DirCount;
- EFI_IMAGE_DOS_HEADER *DosHdr;
- EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
- EFI_IMAGE_OPTIONAL_HEADER32 *OptionalHdr32;
- EFI_IMAGE_OPTIONAL_HEADER64 *OptionalHdr64;
- EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
- EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
- VOID *CodeViewEntryPointer;
+ CHAR8 *PdbPath;
+ UINT32 DirCount;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
+ EFI_IMAGE_OPTIONAL_HEADER32 *OptionalHdr32;
+ EFI_IMAGE_OPTIONAL_HEADER64 *OptionalHdr64;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ VOID *CodeViewEntryPointer;
//
// Init value
//
- CodeViewEntryPointer = NULL;
- PdbPath = NULL;
- DosHdr = ImageBase;
+ CodeViewEntryPointer = NULL;
+ PdbPath = NULL;
+ DosHdr = ImageBase;
//
// Check magic
@@ -777,7 +797,8 @@ GetPdbPath ( if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {
return NULL;
}
- NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *) ((UINT8 *) DosHdr + DosHdr->e_lfanew);
+
+ NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((UINT8 *)DosHdr + DosHdr->e_lfanew);
//
// Check Machine, filter for EBC
//
@@ -793,39 +814,42 @@ GetPdbPath ( // EBC spec says PE32+, but implementation uses PE32. So check dynamically here.
//
if (NtHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
- OptionalHdr32 = (VOID *) &NtHdr->Pe32.OptionalHeader;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ OptionalHdr32 = (VOID *)&NtHdr->Pe32.OptionalHeader;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(OptionalHdr32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
} else if (NtHdr->Pe32Plus.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
- OptionalHdr64 = (VOID *) &NtHdr->Pe32Plus.OptionalHeader;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ OptionalHdr64 = (VOID *)&NtHdr->Pe32Plus.OptionalHeader;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(OptionalHdr64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
} else {
return NULL;
}
+
if (DirectoryEntry->VirtualAddress == 0) {
return NULL;
}
+
//
// Go through DirectoryEntry
//
for (DirCount = 0;
(DirCount < DirectoryEntry->Size / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) && CodeViewEntryPointer == NULL;
DirCount++
- ) {
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (DirectoryEntry->VirtualAddress + (UINTN) ImageBase + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));
+ )
+ {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(DirectoryEntry->VirtualAddress + (UINTN)ImageBase + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));
if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
//
// Match DebugEntry, only CODEVIEW_SIGNATURE_NB10 and CODEVIEW_SIGNATURE_RSDS are supported.
//
- CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageBase);
- switch (*(UINT32 *) CodeViewEntryPointer) {
- case CODEVIEW_SIGNATURE_NB10:
- PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
- break;
- case CODEVIEW_SIGNATURE_RSDS:
- PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
- break;
- default:
- break;
+ CodeViewEntryPointer = (VOID *)((UINTN)DebugEntry->RVA + (UINTN)ImageBase);
+ switch (*(UINT32 *)CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ PdbPath = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
+ break;
+ case CODEVIEW_SIGNATURE_RSDS:
+ PdbPath = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
+ break;
+ default:
+ break;
}
}
}
@@ -853,10 +877,10 @@ MatchPdbAndMap ( IN CHAR16 *MapFileName
)
{
- UINTN PdbNameSize;
- UINTN MapNameSize;
- CHAR8 *PurePdbFileName;
- UINTN Index;
+ UINTN PdbNameSize;
+ UINTN MapNameSize;
+ CHAR8 *PurePdbFileName;
+ UINTN Index;
//
// remove dir name
@@ -867,6 +891,7 @@ MatchPdbAndMap ( PurePdbFileName = &PdbFileName[Index + 1];
}
}
+
PdbFileName = PurePdbFileName;
//
@@ -895,9 +920,9 @@ MatchPdbAndMap ( // BUGBUG: work-around start
//
typedef struct {
- EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
- volatile UINT32 UpdateStatus;
- UINT32 TableSize;
+ EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
+ volatile UINT32 UpdateStatus;
+ UINT32 TableSize;
} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER_OLD;
EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugImageInfoTableHeader;
@@ -932,7 +957,7 @@ For compatibility consideration, we handle 2 cases: **/
VOID
EdbFixDebugImageInfoTable (
- IN OUT EFI_DEBUG_IMAGE_INFO_TABLE_HEADER **DebugImageInfoTableHeader
+ IN OUT EFI_DEBUG_IMAGE_INFO_TABLE_HEADER **DebugImageInfoTableHeader
)
{
mDebugImageInfoTableHeader.EfiDebugImageInfoTable = ((EFI_DEBUG_IMAGE_INFO_TABLE_HEADER_OLD *)(*DebugImageInfoTableHeader))->EfiDebugImageInfoTable;
@@ -941,16 +966,17 @@ EdbFixDebugImageInfoTable ( if ((*DebugImageInfoTableHeader)->UpdateStatus > 3) {
*DebugImageInfoTableHeader = &mDebugImageInfoTableHeader;
- return ;
+ return;
}
if ((*DebugImageInfoTableHeader)->TableSize % (EFI_PAGE_SIZE / (sizeof (VOID *))) != 0) {
*DebugImageInfoTableHeader = &mDebugImageInfoTableHeader;
- return ;
+ return;
}
- return ;
+ return;
}
+
//
// BUGBUG: work-around end
//
@@ -969,20 +995,20 @@ EdbFixDebugImageInfoTable ( **/
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
)
{
- EFI_STATUS Status;
- UINTN ImageNumber;
- EFI_DEBUG_IMAGE_INFO *ImageTable;
- CHAR8 *PdbPath;
- VOID *ImageBase;
- VOID *CandidateImageBase;
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
-
- if (SearchType < 0 || SearchType >= EdbEbcImageRvaSearchTypeMax) {
+ EFI_STATUS Status;
+ UINTN ImageNumber;
+ EFI_DEBUG_IMAGE_INFO *ImageTable;
+ CHAR8 *PdbPath;
+ VOID *ImageBase;
+ VOID *CandidateImageBase;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+
+ if ((SearchType < 0) || (SearchType >= EdbEbcImageRvaSearchTypeMax)) {
return EFI_INVALID_PARAMETER;
}
@@ -1000,13 +1026,14 @@ EdbPatchSymbolRVA ( if (mDebuggerPrivate.DebugImageInfoTableHeader == NULL) {
Status = EfiGetSystemConfigurationTable (
&gEfiDebugImageInfoTableGuid,
- (VOID **) &mDebuggerPrivate.DebugImageInfoTableHeader
+ (VOID **)&mDebuggerPrivate.DebugImageInfoTableHeader
);
if (EFI_ERROR (Status)) {
EDBPrint (L"DebugImageInfoTable not found!\n");
return Status;
}
}
+
DEBUG ((DEBUG_ERROR, "DebugImageInfoTableHeader: %x\n", mDebuggerPrivate.DebugImageInfoTableHeader));
//
@@ -1021,31 +1048,34 @@ EdbPatchSymbolRVA ( // Go through DebugImageInfoTable for each Image
//
CandidateImageBase = NULL;
- ImageTable = mDebuggerPrivate.DebugImageInfoTableHeader->EfiDebugImageInfoTable;
+ ImageTable = mDebuggerPrivate.DebugImageInfoTableHeader->EfiDebugImageInfoTable;
for (ImageNumber = 0; ImageNumber < mDebuggerPrivate.DebugImageInfoTableHeader->TableSize; ImageNumber++) {
if (ImageTable[ImageNumber].NormalImage == NULL) {
continue;
}
+
ImageBase = ImageTable[ImageNumber].NormalImage->LoadedImageProtocolInstance->ImageBase;
//
// Get PDB path
//
- PdbPath = GetPdbPath (ImageBase);
+ PdbPath = GetPdbPath (ImageBase);
if (PdbPath == NULL) {
continue;
}
+
//
// Check PDB name
//
if (!MatchPdbAndMap (PdbPath, FileName)) {
continue;
}
+
DEBUG ((DEBUG_ERROR, "ImageBase: %x\n", ImageBase));
//
// Check SearchType
//
- if (SearchType == EdbEbcImageRvaSearchTypeAny || SearchType == EdbEbcImageRvaSearchTypeFirst) {
+ if ((SearchType == EdbEbcImageRvaSearchTypeAny) || (SearchType == EdbEbcImageRvaSearchTypeFirst)) {
//
// Assign base address and return
//
@@ -1066,6 +1096,7 @@ EdbPatchSymbolRVA ( if (CandidateImageBase == NULL) {
return EFI_NOT_FOUND;
}
+
//
// Assign base address and return
//
@@ -1096,10 +1127,10 @@ MatchObjAndCod ( IN CHAR16 *CodFileName
)
{
- UINTN ObjNameSize;
- UINTN CodNameSize;
- CHAR8 *PureObjFileName;
- UINTN Index;
+ UINTN ObjNameSize;
+ UINTN CodNameSize;
+ CHAR8 *PureObjFileName;
+ UINTN Index;
//
// remove library name
@@ -1111,6 +1142,7 @@ MatchObjAndCod ( break;
}
}
+
ObjFileName = PureObjFileName;
//
@@ -1164,30 +1196,30 @@ typedef enum { **/
CHAR8 *
EdbLoadCodBySymbolByIec (
- IN CHAR8 *Name,
- IN VOID *Buffer,
- IN UINTN BufferSize,
- OUT UINTN *CodeBufferSize,
- OUT UINTN *FuncOffset
+ IN CHAR8 *Name,
+ IN VOID *Buffer,
+ IN UINTN BufferSize,
+ OUT UINTN *CodeBufferSize,
+ OUT UINTN *FuncOffset
)
{
- CHAR8 *LineBuffer;
- CHAR8 *FieldBuffer;
- VOID *BufferStart;
- VOID *BufferEnd;
- UINTN Offset;
- EDB_EBC_COD_PARSE_STATE CodParseState;
- CHAR8 Char[2];
+ CHAR8 *LineBuffer;
+ CHAR8 *FieldBuffer;
+ VOID *BufferStart;
+ VOID *BufferEnd;
+ UINTN Offset;
+ EDB_EBC_COD_PARSE_STATE CodParseState;
+ CHAR8 Char[2];
//
// Init
//
- Char[0] = 9;
- Char[1] = 0;
- LineBuffer = AsciiStrGetNewTokenLine (Buffer, "\n\r");
- Offset = (UINTN)-1;
- BufferStart = NULL;
- BufferEnd = NULL;
+ Char[0] = 9;
+ Char[1] = 0;
+ LineBuffer = AsciiStrGetNewTokenLine (Buffer, "\n\r");
+ Offset = (UINTN)-1;
+ BufferStart = NULL;
+ BufferEnd = NULL;
CodParseState = EdbEbcCodParseStateUninitialized;
//
@@ -1195,97 +1227,101 @@ EdbLoadCodBySymbolByIec ( //
while (LineBuffer != NULL) {
switch (CodParseState) {
- case EdbEbcCodParseStateUninitialized:
- //
- // check mark_begin, begin to check line after this match
- //
- if (AsciiStrCmp (LineBuffer, "; mark_begin;") == 0) {
- CodParseState = EdbEbcCodParseStateSymbolInitialized;
- }
- LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
- PatchForAsciiStrTokenBefore (LineBuffer, '\n');
- break;
+ case EdbEbcCodParseStateUninitialized:
+ //
+ // check mark_begin, begin to check line after this match
+ //
+ if (AsciiStrCmp (LineBuffer, "; mark_begin;") == 0) {
+ CodParseState = EdbEbcCodParseStateSymbolInitialized;
+ }
- case EdbEbcCodParseStateSymbolInitialized:
- //
- // check mark_end, not check line after this match
- //
- if (AsciiStrCmp (LineBuffer, "; mark_end;") == 0) {
- CodParseState = EdbEbcCodParseStateUninitialized;
LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
PatchForAsciiStrTokenBefore (LineBuffer, '\n');
break;
- }
- //
- // not check this line if the first char is as follows
- //
- if ((*LineBuffer == 0) ||
- (*LineBuffer == '$') ||
- (*LineBuffer == ';') ||
- (*LineBuffer == '_') ||
- (*LineBuffer == ' ')) {
+ case EdbEbcCodParseStateSymbolInitialized:
+ //
+ // check mark_end, not check line after this match
+ //
+ if (AsciiStrCmp (LineBuffer, "; mark_end;") == 0) {
+ CodParseState = EdbEbcCodParseStateUninitialized;
+ LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
+ PatchForAsciiStrTokenBefore (LineBuffer, '\n');
+ break;
+ }
+
+ //
+ // not check this line if the first char is as follows
+ //
+ if ((*LineBuffer == 0) ||
+ (*LineBuffer == '$') ||
+ (*LineBuffer == ';') ||
+ (*LineBuffer == '_') ||
+ (*LineBuffer == ' '))
+ {
+ LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
+ PatchForAsciiStrTokenBefore (LineBuffer, '\n');
+ break;
+ }
+
+ //
+ // get function name, function name is followed by char 0x09.
+ //
+ FieldBuffer = AsciiStrGetNewTokenField (LineBuffer, Char);
+ ASSERT (FieldBuffer != NULL);
+ if (AsciiStriCmp (FieldBuffer, Name) == 0) {
+ BufferStart = FieldBuffer;
+ CodParseState = EdbEbcCodParseStateSymbolStart;
+ }
+
+ PatchForAsciiStrTokenAfter (FieldBuffer, 0x9);
+
+ //
+ // Get next line
+ //
LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
PatchForAsciiStrTokenBefore (LineBuffer, '\n');
break;
- }
- //
- // get function name, function name is followed by char 0x09.
- //
- FieldBuffer = AsciiStrGetNewTokenField (LineBuffer, Char);
- ASSERT (FieldBuffer != NULL);
- if (AsciiStriCmp (FieldBuffer, Name) == 0) {
- BufferStart = FieldBuffer;
- CodParseState = EdbEbcCodParseStateSymbolStart;
- }
- PatchForAsciiStrTokenAfter (FieldBuffer, 0x9);
-
- //
- // Get next line
- //
- LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
- PatchForAsciiStrTokenBefore (LineBuffer, '\n');
- break;
-
- case EdbEbcCodParseStateSymbolStart:
- //
- // check mark_end, if this match, means the function is found successfully.
- //
- if (AsciiStrCmp (LineBuffer, "; mark_end;") == 0) {
- CodParseState = EdbEbcCodParseStateSymbolEnd;
+ case EdbEbcCodParseStateSymbolStart:
//
- // prepare CodeBufferSize, FuncOffset, and FuncStart to return
+ // check mark_end, if this match, means the function is found successfully.
//
- BufferEnd = LineBuffer + sizeof("; mark_end;") - 1;
- *CodeBufferSize = (UINTN)BufferEnd - (UINTN)BufferStart;
- *FuncOffset = Offset;
- PatchForAsciiStrTokenAfter (LineBuffer, '\n');
- return BufferStart;
- }
+ if (AsciiStrCmp (LineBuffer, "; mark_end;") == 0) {
+ CodParseState = EdbEbcCodParseStateSymbolEnd;
+ //
+ // prepare CodeBufferSize, FuncOffset, and FuncStart to return
+ //
+ BufferEnd = LineBuffer + sizeof ("; mark_end;") - 1;
+ *CodeBufferSize = (UINTN)BufferEnd - (UINTN)BufferStart;
+ *FuncOffset = Offset;
+ PatchForAsciiStrTokenAfter (LineBuffer, '\n');
+ return BufferStart;
+ }
- //
- // Get function offset
- //
- if ((Offset == (UINTN)-1) &&
- (*LineBuffer == ' ')) {
- FieldBuffer = AsciiStrGetNewTokenField (LineBuffer + 2, " ");
- Offset = AsciiXtoi (FieldBuffer);
- PatchForAsciiStrTokenAfter (FieldBuffer, ' ');
- }
+ //
+ // Get function offset
+ //
+ if ((Offset == (UINTN)-1) &&
+ (*LineBuffer == ' '))
+ {
+ FieldBuffer = AsciiStrGetNewTokenField (LineBuffer + 2, " ");
+ Offset = AsciiXtoi (FieldBuffer);
+ PatchForAsciiStrTokenAfter (FieldBuffer, ' ');
+ }
- //
- // Get next line
- //
- LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
- PatchForAsciiStrTokenBefore (LineBuffer, '\n');
- break;
+ //
+ // Get next line
+ //
+ LineBuffer = AsciiStrGetNextTokenLine ("\n\r");
+ PatchForAsciiStrTokenBefore (LineBuffer, '\n');
+ break;
- case EdbEbcCodParseStateSymbolEnd:
- break;
+ case EdbEbcCodParseStateSymbolEnd:
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -1310,11 +1346,11 @@ EdbLoadCodBySymbolByIec ( **/
CHAR8 *
EdbLoadCodBySymbol (
- IN CHAR8 *Name,
- IN VOID *Buffer,
- IN UINTN BufferSize,
- OUT UINTN *CodeBufferSize,
- OUT UINTN *FuncOffset
+ IN CHAR8 *Name,
+ IN VOID *Buffer,
+ IN UINTN BufferSize,
+ OUT UINTN *CodeBufferSize,
+ OUT UINTN *FuncOffset
)
{
//
@@ -1342,7 +1378,7 @@ EdbFindCodeFromObject ( IN CHAR16 *FileName
)
{
- UINTN EntryIndex;
+ UINTN EntryIndex;
//
// Go througn each Entry in this Object
@@ -1352,21 +1388,25 @@ EdbFindCodeFromObject ( // This check is for Function only
//
if ((Object->Entry[EntryIndex].Type != EfiDebuggerSymbolFunction) &&
- (Object->Entry[EntryIndex].Type != EfiDebuggerSymbolStaticFunction)) {
+ (Object->Entry[EntryIndex].Type != EfiDebuggerSymbolStaticFunction))
+ {
continue;
}
+
//
// Skip match varbss_init function, because they has no source code
//
- if (AsciiStrnCmp (Object->Entry[EntryIndex].Name, "varbss_init", sizeof("varbss_init") - 1) == 0) {
+ if (AsciiStrnCmp (Object->Entry[EntryIndex].Name, "varbss_init", sizeof ("varbss_init") - 1) == 0) {
continue;
}
+
//
// check the name
//
if (!MatchObjAndCod (Object->Entry[EntryIndex].ObjName, FileName)) {
continue;
}
+
//
// found it, return source buffer
//
@@ -1396,18 +1436,18 @@ EdbFindCodeFromObject ( **/
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
)
{
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
- UINTN ObjectIndex;
- UINTN EntryIndex;
- VOID *SourceBuffer;
- EFI_STATUS Status;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ UINTN ObjectIndex;
+ UINTN EntryIndex;
+ VOID *SourceBuffer;
+ EFI_STATUS Status;
//
// Find Symbol
@@ -1426,12 +1466,13 @@ EdbLoadCode ( // unnload duplicated code
//
Status = EdbUnloadCode (DebuggerPrivate, MapFileName, FileName, &SourceBuffer);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Unload Duplicated Code File Error!\n"));
return Status;
}
+
Status = EdbDeleteCodeBuffer (DebuggerPrivate, MapFileName, FileName, SourceBuffer);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Delete Duplicated Code File Error!\n"));
return Status;
}
@@ -1446,21 +1487,25 @@ EdbLoadCode ( // load symbol for function only
//
if ((Object->Entry[EntryIndex].Type != EfiDebuggerSymbolFunction) &&
- (Object->Entry[EntryIndex].Type != EfiDebuggerSymbolStaticFunction)) {
+ (Object->Entry[EntryIndex].Type != EfiDebuggerSymbolStaticFunction))
+ {
continue;
}
+
//
// skip varbss_init
//
- if (AsciiStrnCmp (Object->Entry[EntryIndex].Name, "varbss_init", sizeof("varbss_init") - 1) == 0) {
+ if (AsciiStrnCmp (Object->Entry[EntryIndex].Name, "varbss_init", sizeof ("varbss_init") - 1) == 0) {
continue;
}
+
//
// Check the name
//
if (!MatchObjAndCod (Object->Entry[EntryIndex].ObjName, FileName)) {
continue;
}
+
//
// load code for this symbol
//
@@ -1483,7 +1528,7 @@ EdbLoadCode ( if (Object->Entry[EntryIndex].CodBuffer != NULL) {
*((UINT8 *)Object->Entry[EntryIndex].CodBuffer + Object->Entry[EntryIndex].CodBufferSize) = 0;
DEBUG ((DEBUG_ERROR, " CodeSymbol: %a, FuncOffset: 0x05%x\n", Object->Entry[EntryIndex].Name, Object->Entry[EntryIndex].FuncOffsetBase));
-// DEBUG ((DEBUG_ERROR, " [CODE]:\n%a\n", Object->Entry[EntryIndex].CodBuffer));
+ // DEBUG ((DEBUG_ERROR, " [CODE]:\n%a\n", Object->Entry[EntryIndex].CodBuffer));
}
}
@@ -1507,15 +1552,15 @@ 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
)
{
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
- UINTN ObjectIndex;
- UINTN EntryIndex;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ UINTN ObjectIndex;
+ UINTN EntryIndex;
//
// Find Symbol
@@ -1540,22 +1585,26 @@ EdbUnloadCode ( //
for (EntryIndex = 0; EntryIndex < Object->EntryCount; EntryIndex++) {
if ((Object->Entry[EntryIndex].Type != EfiDebuggerSymbolFunction) &&
- (Object->Entry[EntryIndex].Type != EfiDebuggerSymbolStaticFunction)) {
+ (Object->Entry[EntryIndex].Type != EfiDebuggerSymbolStaticFunction))
+ {
continue;
}
- if (AsciiStrnCmp (Object->Entry[EntryIndex].Name, "varbss_init", sizeof("varbss_init") - 1) == 0) {
+
+ if (AsciiStrnCmp (Object->Entry[EntryIndex].Name, "varbss_init", sizeof ("varbss_init") - 1) == 0) {
continue;
}
+
if (!MatchObjAndCod (Object->Entry[EntryIndex].ObjName, FileName)) {
continue;
}
+
//
// clean up the buffer
//
- Object->Entry[EntryIndex].CodBuffer = NULL;
- Object->Entry[EntryIndex].CodBufferSize = 0;
+ Object->Entry[EntryIndex].CodBuffer = NULL;
+ Object->Entry[EntryIndex].CodBufferSize = 0;
Object->Entry[EntryIndex].FuncOffsetBase = 0;
- Object->Entry[EntryIndex].SourceBuffer = NULL;
+ Object->Entry[EntryIndex].SourceBuffer = NULL;
}
//
@@ -1579,15 +1628,15 @@ 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
)
{
- UINTN Index;
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ UINTN Index;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
//
// Find Symbol
@@ -1602,8 +1651,8 @@ EdbAddCodeBuffer ( // Add it to last entry
//
for (Index = 0; Object->SourceBuffer[Index] != NULL; Index++) {
- ;
}
+
Object->SourceBuffer[Index] = SourceBuffer;
return EFI_SUCCESS;
@@ -1623,14 +1672,14 @@ 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
)
{
- UINTN Index;
- EFI_DEBUGGER_SYMBOL_OBJECT *Object;
+ UINTN Index;
+ EFI_DEBUGGER_SYMBOL_OBJECT *Object;
//
// Find Symbol
@@ -1665,6 +1714,7 @@ EdbDeleteCodeBuffer ( for (Index = Index + 1; Object->SourceBuffer[Index] != NULL; Index++) {
Object->SourceBuffer[Index - 1] = Object->SourceBuffer[Index];
}
+
Object->SourceBuffer[Index - 1] = NULL;
return EFI_SUCCESS;
@@ -1681,7 +1731,7 @@ EdbDeleteCodeBuffer ( **/
CHAR8 *
FindSymbolStr (
- IN UINTN Address
+ IN UINTN Address
)
{
UINTN ObjectIndex;
@@ -1730,8 +1780,8 @@ FindSymbolStr ( **/
UINTN
EdbGetLineNumberAndOffsetFromThisLine (
- IN VOID *Line,
- OUT UINTN *Offset
+ IN VOID *Line,
+ OUT UINTN *Offset
)
{
UINTN LineNumber;
@@ -1740,7 +1790,7 @@ EdbGetLineNumberAndOffsetFromThisLine ( LineNumber = (UINTN)-1;
LineBuffer = Line;
- *Offset = (UINTN)-1;
+ *Offset = (UINTN)-1;
while (LineBuffer != NULL) {
//
@@ -1756,7 +1806,7 @@ EdbGetLineNumberAndOffsetFromThisLine ( if (*(LineBuffer + 2) != ' ') {
if (*Offset == (UINTN)-1) {
FieldBuffer = AsciiStrGetNewTokenField (LineBuffer + 2, " ");
- *Offset = AsciiXtoi (FieldBuffer);
+ *Offset = AsciiXtoi (FieldBuffer);
PatchForAsciiStrTokenAfter (FieldBuffer, ' ');
}
}
@@ -1779,6 +1829,7 @@ EdbGetLineNumberAndOffsetFromThisLine ( PatchForAsciiStrTokenBefore (LineBuffer, '\n');
continue;
}
+
//
// 3. line number
//
@@ -1835,14 +1886,14 @@ EdbGetLineNumberFromCode ( UINTN CandidateLineNumber;
UINTN CandidateOffset;
- if (SearchType < 0 || SearchType >= EdbEbcLineSearchTypeMax) {
+ if ((SearchType < 0) || (SearchType >= EdbEbcLineSearchTypeMax)) {
return (UINTN)-1;
}
- LineNumber = (UINTN)-1;
+ LineNumber = (UINTN)-1;
CandidateLineNumber = (UINTN)-1;
- CandidateOffset = (UINTN)-1;
- LineBuffer = AsciiStrGetNewTokenLine (Entry->CodBuffer, "\n");
+ CandidateOffset = (UINTN)-1;
+ LineBuffer = AsciiStrGetNewTokenLine (Entry->CodBuffer, "\n");
while (LineBuffer != NULL) {
if (*LineBuffer != ' ') {
LineBuffer = AsciiStrGetNextTokenLine ("\n");
@@ -1904,7 +1955,7 @@ EdbGetLineNumberFromCode ( }
CandidateLineNumber = LineNumber;
- CandidateOffset = Offset;
+ CandidateOffset = Offset;
LineBuffer = AsciiStrGetNextTokenLine ("\n");
PatchForAsciiStrTokenBefore (LineBuffer, '\n');
@@ -1945,7 +1996,7 @@ EdbGetSourceStrFromCodeByLine ( VOID *FuncStart;
UINTN Number;
- FuncStart = NULL;
+ FuncStart = NULL;
LineBuffer = AsciiStrGetNewTokenLine (Entry->CodBuffer, "\n");
while (LineBuffer != NULL) {
if (*LineBuffer != ';') {
@@ -1957,6 +2008,7 @@ EdbGetSourceStrFromCodeByLine ( PatchForAsciiStrTokenAfter (LineBuffer, '\n');
return FuncStart;
}
+
LineBuffer = AsciiStrGetNextTokenLine ("\n");
PatchForAsciiStrTokenBefore (LineBuffer, '\n');
continue;
@@ -1966,7 +2018,7 @@ EdbGetSourceStrFromCodeByLine ( // Check LineNumber
//
FieldBuffer = AsciiStrGetNewTokenField (LineBuffer + 1, " ");
- Number = AsciiAtoi (FieldBuffer);
+ Number = AsciiAtoi (FieldBuffer);
PatchForAsciiStrTokenAfter (FieldBuffer, ' ');
if (Number != LineNumber) {
LineBuffer = AsciiStrGetNextTokenLine ("\n");
@@ -2032,25 +2084,25 @@ EdbGetSourceStrFromCode ( **/
UINTN
EdbPrintSource (
- IN UINTN Address,
- IN BOOLEAN IsPrint
+ IN UINTN Address,
+ IN BOOLEAN IsPrint
)
{
- UINTN SymbolAddress;
- EFI_DEBUGGER_SYMBOL_OBJECT *RetObject;
- EFI_DEBUGGER_SYMBOL_ENTRY *RetEntry;
- UINTN FuncOffset;
- UINT8 *FuncStart;
- UINT8 *FuncEnd;
- UINT8 *FuncIndex;
- CHAR8 Buffer[EFI_DEBUG_MAX_PRINT_BUFFER];
- UINTN BufferSize;
+ UINTN SymbolAddress;
+ EFI_DEBUGGER_SYMBOL_OBJECT *RetObject;
+ EFI_DEBUGGER_SYMBOL_ENTRY *RetEntry;
+ UINTN FuncOffset;
+ UINT8 *FuncStart;
+ UINT8 *FuncEnd;
+ UINT8 *FuncIndex;
+ CHAR8 Buffer[EFI_DEBUG_MAX_PRINT_BUFFER];
+ UINTN BufferSize;
//
// need we display symbol
//
if (!mDebuggerPrivate.DebuggerSymbolContext.DisplaySymbol) {
- return 0 ;
+ return 0;
}
//
@@ -2062,8 +2114,8 @@ EdbPrintSource ( &RetObject,
&RetEntry
);
- if (SymbolAddress == 0 || RetEntry == NULL) {
- return 0 ;
+ if ((SymbolAddress == 0) || (RetEntry == NULL)) {
+ return 0;
}
FuncOffset = Address - SymbolAddress + RetEntry->FuncOffsetBase;
@@ -2071,9 +2123,9 @@ EdbPrintSource ( //
// Get Func String
//
- FuncStart = EdbGetSourceStrFromCode (RetEntry, FuncOffset, (VOID**) &FuncEnd);
+ FuncStart = EdbGetSourceStrFromCode (RetEntry, FuncOffset, (VOID **)&FuncEnd);
if (FuncStart == NULL) {
- return 0 ;
+ return 0;
}
//
@@ -2096,15 +2148,17 @@ EdbPrintSource ( } else {
BufferSize = EFI_DEBUG_MAX_PRINT_BUFFER - 3;
}
+
if (BufferSize != 0) {
CopyMem (Buffer, FuncStart, BufferSize);
}
+
Buffer[BufferSize] = 0;
EDBPrint (L"%a\n", Buffer);
FuncStart = FuncIndex + 1;
FuncIndex = FuncStart;
} else {
- FuncIndex ++;
+ FuncIndex++;
}
}
@@ -2113,7 +2167,7 @@ EdbPrintSource ( //
*(UINT8 *)FuncEnd = '\n';
- return 1 ;
+ return 1;
}
/**
@@ -2135,7 +2189,7 @@ GetMapfileAndSymbol ( CHAR16 *Ch;
*MapfileName = NULL;
- *SymbolName = Symbol;
+ *SymbolName = Symbol;
for (Ch = Symbol; *Ch != 0; Ch++) {
//
@@ -2143,13 +2197,13 @@ GetMapfileAndSymbol ( //
if (*Ch == L':') {
*MapfileName = Symbol;
- *Ch = 0;
- *SymbolName = Ch + 1;
+ *Ch = 0;
+ *SymbolName = Ch + 1;
break;
}
}
- return ;
+ return;
}
/**
@@ -2166,8 +2220,8 @@ GetMapfileAndSymbol ( **/
EFI_STATUS
Symboltoi (
- IN CHAR16 *Symbol,
- OUT UINTN *Address
+ IN CHAR16 *Symbol,
+ OUT UINTN *Address
)
{
UINTN ObjectIndex;
@@ -2194,6 +2248,7 @@ Symboltoi ( if ((MapfileName != NULL) && (StriCmp (Object[ObjectIndex].Name, MapfileName) != 0)) {
continue;
}
+
//
// Go through each entry
//
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h index f82e5b76c7..a82e9439b6 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h @@ -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
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c index b516147ff7..6b52ec55bc 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c @@ -52,7 +52,7 @@ EbcDebuggerHookUnload ( **/
VOID
EbcDebuggerHookEbcUnloadImage (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
return;
@@ -67,7 +67,7 @@ EbcDebuggerHookEbcUnloadImage ( **/
VOID
EbcDebuggerHookExecuteEbcImageEntryPoint (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -82,7 +82,7 @@ EbcDebuggerHookExecuteEbcImageEntryPoint ( **/
VOID
EbcDebuggerHookEbcInterpret (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -96,7 +96,7 @@ EbcDebuggerHookEbcInterpret ( **/
VOID
EbcDebuggerHookExecuteStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -110,7 +110,7 @@ EbcDebuggerHookExecuteStart ( **/
VOID
EbcDebuggerHookExecuteEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -125,7 +125,7 @@ EbcDebuggerHookExecuteEnd ( **/
VOID
EbcDebuggerHookCALLStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -140,7 +140,7 @@ EbcDebuggerHookCALLStart ( **/
VOID
EbcDebuggerHookCALLEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -155,7 +155,7 @@ EbcDebuggerHookCALLEnd ( **/
VOID
EbcDebuggerHookCALLEXStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -170,7 +170,7 @@ EbcDebuggerHookCALLEXStart ( **/
VOID
EbcDebuggerHookCALLEXEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -185,7 +185,7 @@ EbcDebuggerHookCALLEXEnd ( **/
VOID
EbcDebuggerHookRETStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -200,7 +200,7 @@ EbcDebuggerHookRETStart ( **/
VOID
EbcDebuggerHookRETEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -215,7 +215,7 @@ EbcDebuggerHookRETEnd ( **/
VOID
EbcDebuggerHookJMPStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -230,7 +230,7 @@ EbcDebuggerHookJMPStart ( **/
VOID
EbcDebuggerHookJMPEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -245,7 +245,7 @@ EbcDebuggerHookJMPEnd ( **/
VOID
EbcDebuggerHookJMP8Start (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
@@ -260,7 +260,7 @@ EbcDebuggerHookJMP8Start ( **/
VOID
EbcDebuggerHookJMP8End (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
return;
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h index b166e505a4..79a946f873 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h @@ -27,9 +27,9 @@ **/
EFI_STATUS
EbcDebugSignalException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EXCEPTION_FLAGS ExceptionFlags,
- IN VM_CONTEXT *VmPtr
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN EXCEPTION_FLAGS ExceptionFlags,
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -66,10 +66,9 @@ EbcDebuggerHookUnload ( **/
VOID
EbcDebuggerHookEbcUnloadImage (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
);
-
/**
Hooks in EbcSupport.c
@@ -79,7 +78,7 @@ EbcDebuggerHookEbcUnloadImage ( **/
VOID
EbcDebuggerHookExecuteEbcImageEntryPoint (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -91,10 +90,9 @@ EbcDebuggerHookExecuteEbcImageEntryPoint ( **/
VOID
EbcDebuggerHookEbcInterpret (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
-
/**
The hook in EbcExecute, before ExecuteFunction.
@@ -103,7 +101,7 @@ EbcDebuggerHookEbcInterpret ( **/
VOID
EbcDebuggerHookExecuteStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -114,7 +112,7 @@ EbcDebuggerHookExecuteStart ( **/
VOID
EbcDebuggerHookExecuteEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -125,7 +123,7 @@ EbcDebuggerHookExecuteEnd ( **/
VOID
EbcDebuggerHookCALLStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -137,7 +135,7 @@ EbcDebuggerHookCALLStart ( **/
VOID
EbcDebuggerHookCALLEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -149,7 +147,7 @@ EbcDebuggerHookCALLEnd ( **/
VOID
EbcDebuggerHookCALLEXStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -161,7 +159,7 @@ EbcDebuggerHookCALLEXStart ( **/
VOID
EbcDebuggerHookCALLEXEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -173,7 +171,7 @@ EbcDebuggerHookCALLEXEnd ( **/
VOID
EbcDebuggerHookRETStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -186,10 +184,9 @@ EbcDebuggerHookRETStart ( **/
VOID
EbcDebuggerHookRETEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
-
/**
The hook in ExecuteJMP, before move IP.
@@ -199,7 +196,7 @@ EbcDebuggerHookRETEnd ( **/
VOID
EbcDebuggerHookJMPStart (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -211,7 +208,7 @@ EbcDebuggerHookJMPStart ( **/
VOID
EbcDebuggerHookJMPEnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -223,7 +220,7 @@ EbcDebuggerHookJMPEnd ( **/
VOID
EbcDebuggerHookJMP8Start (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -235,7 +232,7 @@ EbcDebuggerHookJMP8Start ( **/
VOID
EbcDebuggerHookJMP8End (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
#endif
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c index 1c4a4f5155..82a7782fb9 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c @@ -10,31 +10,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "EbcExecute.h"
#include "EbcDebuggerHook.h"
-
//
// Define some useful data size constants to allow switch statements based on
// size of operands or data.
//
-#define DATA_SIZE_INVALID 0
-#define DATA_SIZE_8 1
-#define DATA_SIZE_16 2
-#define DATA_SIZE_32 4
-#define DATA_SIZE_64 8
-#define DATA_SIZE_N 48 // 4 or 8
+#define DATA_SIZE_INVALID 0
+#define DATA_SIZE_8 1
+#define DATA_SIZE_16 2
+#define DATA_SIZE_32 4
+#define DATA_SIZE_64 8
+#define DATA_SIZE_N 48 // 4 or 8
//
// Structure we'll use to dispatch opcodes to execute functions.
//
typedef struct {
- EFI_STATUS (*ExecuteFunction) (IN VM_CONTEXT * VmPtr);
-}
-VM_TABLE_ENTRY;
+ EFI_STATUS (*ExecuteFunction)(
+ IN VM_CONTEXT *VmPtr
+ );
+} VM_TABLE_ENTRY;
typedef
UINT64
(*DATA_MANIP_EXEC_FUNCTION) (
- IN VM_CONTEXT * VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -61,8 +61,8 @@ UINT64 **/
INT16
VmReadIndex16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
);
/**
@@ -77,8 +77,8 @@ VmReadIndex16 ( **/
INT32
VmReadIndex32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
);
/**
@@ -93,8 +93,8 @@ VmReadIndex32 ( **/
INT64
VmReadIndex64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
);
/**
@@ -108,8 +108,8 @@ VmReadIndex64 ( **/
UINT8
VmReadMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -123,8 +123,8 @@ VmReadMem8 ( **/
UINT16
VmReadMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -138,8 +138,8 @@ VmReadMem16 ( **/
UINT32
VmReadMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -153,8 +153,8 @@ VmReadMem32 ( **/
UINT64
VmReadMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -168,8 +168,8 @@ VmReadMem64 ( **/
UINTN
VmReadMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -197,9 +197,9 @@ VmReadMemN ( **/
EFI_STATUS
VmWriteMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT8 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT8 Data
);
/**
@@ -227,9 +227,9 @@ VmWriteMem8 ( **/
EFI_STATUS
VmWriteMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT16 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT16 Data
);
/**
@@ -257,9 +257,9 @@ VmWriteMem16 ( **/
EFI_STATUS
VmWriteMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT32 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT32 Data
);
/**
@@ -276,8 +276,8 @@ VmWriteMem32 ( **/
UINT16
VmReadCode16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -294,8 +294,8 @@ VmReadCode16 ( **/
UINT32
VmReadCode32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -312,8 +312,8 @@ VmReadCode32 ( **/
UINT64
VmReadCode64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -332,8 +332,8 @@ VmReadCode64 ( **/
INT8
VmReadImmed8 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -352,8 +352,8 @@ VmReadImmed8 ( **/
INT16
VmReadImmed16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -372,8 +372,8 @@ VmReadImmed16 ( **/
INT32
VmReadImmed32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -392,8 +392,8 @@ VmReadImmed32 ( **/
INT64
VmReadImmed64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
);
/**
@@ -417,8 +417,8 @@ VmReadImmed64 ( **/
UINTN
ConvertStackAddr (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
);
/**
@@ -441,13 +441,14 @@ ConvertStackAddr ( **/
EFI_STATUS
ExecuteDataManip (
- IN VM_CONTEXT *VmPtr,
- IN BOOLEAN IsSignedOp
+ IN VM_CONTEXT *VmPtr,
+ IN BOOLEAN IsSignedOp
);
//
// Functions that execute VM opcodes
//
+
/**
Execute the EBC BREAK instruction.
@@ -458,7 +459,7 @@ ExecuteDataManip ( **/
EFI_STATUS
ExecuteBREAK (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -488,7 +489,7 @@ ExecuteBREAK ( **/
EFI_STATUS
ExecuteJMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -504,7 +505,7 @@ ExecuteJMP ( **/
EFI_STATUS
ExecuteJMP8 (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -525,7 +526,7 @@ ExecuteJMP8 ( **/
EFI_STATUS
ExecuteCALL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -541,7 +542,7 @@ ExecuteCALL ( **/
EFI_STATUS
ExecuteRET (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -558,7 +559,7 @@ ExecuteRET ( **/
EFI_STATUS
ExecuteCMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -575,7 +576,7 @@ ExecuteCMP ( **/
EFI_STATUS
ExecuteCMPI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -601,7 +602,7 @@ ExecuteCMPI ( **/
EFI_STATUS
ExecuteMOVxx (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -627,7 +628,7 @@ ExecuteMOVxx ( **/
EFI_STATUS
ExecuteMOVI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -646,7 +647,7 @@ ExecuteMOVI ( **/
EFI_STATUS
ExecuteMOVIn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -665,7 +666,7 @@ ExecuteMOVIn ( **/
EFI_STATUS
ExecuteMOVREL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -681,7 +682,7 @@ ExecuteMOVREL ( **/
EFI_STATUS
ExecutePUSHn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -697,7 +698,7 @@ ExecutePUSHn ( **/
EFI_STATUS
ExecutePUSH (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -713,7 +714,7 @@ ExecutePUSH ( **/
EFI_STATUS
ExecutePOPn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -729,7 +730,7 @@ ExecutePOPn ( **/
EFI_STATUS
ExecutePOP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -751,7 +752,7 @@ ExecutePOP ( **/
EFI_STATUS
ExecuteSignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -773,7 +774,7 @@ ExecuteSignedDataManip ( **/
EFI_STATUS
ExecuteUnsignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -790,7 +791,7 @@ ExecuteUnsignedDataManip ( **/
EFI_STATUS
ExecuteLOADSP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -807,7 +808,7 @@ ExecuteLOADSP ( **/
EFI_STATUS
ExecuteSTORESP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -831,7 +832,7 @@ ExecuteSTORESP ( **/
EFI_STATUS
ExecuteMOVsnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
/**
@@ -855,12 +856,13 @@ ExecuteMOVsnd ( **/
EFI_STATUS
ExecuteMOVsnw (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
//
// Data manipulation subfunctions
//
+
/**
Execute the EBC NOT instruction.s
@@ -876,9 +878,9 @@ ExecuteMOVsnw ( **/
UINT64
ExecuteNOT (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -896,9 +898,9 @@ ExecuteNOT ( **/
UINT64
ExecuteNEG (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -916,9 +918,9 @@ ExecuteNEG ( **/
UINT64
ExecuteADD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -936,9 +938,9 @@ ExecuteADD ( **/
UINT64
ExecuteSUB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -956,9 +958,9 @@ ExecuteSUB ( **/
UINT64
ExecuteMUL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -976,9 +978,9 @@ ExecuteMUL ( **/
UINT64
ExecuteMULU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -996,9 +998,9 @@ ExecuteMULU ( **/
UINT64
ExecuteDIV (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1016,9 +1018,9 @@ ExecuteDIV ( **/
UINT64
ExecuteDIVU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1036,9 +1038,9 @@ ExecuteDIVU ( **/
UINT64
ExecuteMOD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1056,9 +1058,9 @@ ExecuteMOD ( **/
UINT64
ExecuteMODU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1076,9 +1078,9 @@ ExecuteMODU ( **/
UINT64
ExecuteAND (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1096,9 +1098,9 @@ ExecuteAND ( **/
UINT64
ExecuteOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1116,9 +1118,9 @@ ExecuteOR ( **/
UINT64
ExecuteXOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1136,9 +1138,9 @@ ExecuteXOR ( **/
UINT64
ExecuteSHL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1156,9 +1158,9 @@ ExecuteSHL ( **/
UINT64
ExecuteSHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1176,9 +1178,9 @@ ExecuteSHR ( **/
UINT64
ExecuteASHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1196,9 +1198,9 @@ ExecuteASHR ( **/
UINT64
ExecuteEXTNDB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1216,9 +1218,9 @@ ExecuteEXTNDB ( **/
UINT64
ExecuteEXTNDW (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
/**
@@ -1236,16 +1238,16 @@ ExecuteEXTNDW ( **/
UINT64
ExecuteEXTNDD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
);
//
// Once we retrieve the operands for the data manipulation instructions,
// call these functions to perform the operation.
//
-CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {
+CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {
ExecuteNOT,
ExecuteNEG,
ExecuteADD,
@@ -1267,77 +1269,77 @@ CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = { ExecuteEXTNDD,
};
-CONST VM_TABLE_ENTRY mVmOpcodeTable[] = {
- { ExecuteBREAK }, // opcode 0x00
- { ExecuteJMP }, // opcode 0x01
- { ExecuteJMP8 }, // opcode 0x02
- { ExecuteCALL }, // opcode 0x03
- { ExecuteRET }, // opcode 0x04
- { ExecuteCMP }, // opcode 0x05 CMPeq
- { ExecuteCMP }, // opcode 0x06 CMPlte
- { ExecuteCMP }, // opcode 0x07 CMPgte
- { ExecuteCMP }, // opcode 0x08 CMPulte
- { ExecuteCMP }, // opcode 0x09 CMPugte
+CONST VM_TABLE_ENTRY mVmOpcodeTable[] = {
+ { ExecuteBREAK }, // opcode 0x00
+ { ExecuteJMP }, // opcode 0x01
+ { ExecuteJMP8 }, // opcode 0x02
+ { ExecuteCALL }, // opcode 0x03
+ { ExecuteRET }, // opcode 0x04
+ { ExecuteCMP }, // opcode 0x05 CMPeq
+ { ExecuteCMP }, // opcode 0x06 CMPlte
+ { ExecuteCMP }, // opcode 0x07 CMPgte
+ { ExecuteCMP }, // opcode 0x08 CMPulte
+ { ExecuteCMP }, // opcode 0x09 CMPugte
{ ExecuteUnsignedDataManip }, // opcode 0x0A NOT
- { ExecuteSignedDataManip }, // opcode 0x0B NEG
- { ExecuteSignedDataManip }, // opcode 0x0C ADD
- { ExecuteSignedDataManip }, // opcode 0x0D SUB
- { ExecuteSignedDataManip }, // opcode 0x0E MUL
+ { ExecuteSignedDataManip }, // opcode 0x0B NEG
+ { ExecuteSignedDataManip }, // opcode 0x0C ADD
+ { ExecuteSignedDataManip }, // opcode 0x0D SUB
+ { ExecuteSignedDataManip }, // opcode 0x0E MUL
{ ExecuteUnsignedDataManip }, // opcode 0x0F MULU
- { ExecuteSignedDataManip }, // opcode 0x10 DIV
+ { ExecuteSignedDataManip }, // opcode 0x10 DIV
{ ExecuteUnsignedDataManip }, // opcode 0x11 DIVU
- { ExecuteSignedDataManip }, // opcode 0x12 MOD
+ { ExecuteSignedDataManip }, // opcode 0x12 MOD
{ ExecuteUnsignedDataManip }, // opcode 0x13 MODU
{ ExecuteUnsignedDataManip }, // opcode 0x14 AND
{ ExecuteUnsignedDataManip }, // opcode 0x15 OR
{ ExecuteUnsignedDataManip }, // opcode 0x16 XOR
{ ExecuteUnsignedDataManip }, // opcode 0x17 SHL
{ ExecuteUnsignedDataManip }, // opcode 0x18 SHR
- { ExecuteSignedDataManip }, // opcode 0x19 ASHR
+ { ExecuteSignedDataManip }, // opcode 0x19 ASHR
{ ExecuteUnsignedDataManip }, // opcode 0x1A EXTNDB
{ ExecuteUnsignedDataManip }, // opcode 0x1B EXTNDW
{ ExecuteUnsignedDataManip }, // opcode 0x1C EXTNDD
- { ExecuteMOVxx }, // opcode 0x1D MOVBW
- { ExecuteMOVxx }, // opcode 0x1E MOVWW
- { ExecuteMOVxx }, // opcode 0x1F MOVDW
- { ExecuteMOVxx }, // opcode 0x20 MOVQW
- { ExecuteMOVxx }, // opcode 0x21 MOVBD
- { ExecuteMOVxx }, // opcode 0x22 MOVWD
- { ExecuteMOVxx }, // opcode 0x23 MOVDD
- { ExecuteMOVxx }, // opcode 0x24 MOVQD
- { ExecuteMOVsnw }, // opcode 0x25 MOVsnw
- { ExecuteMOVsnd }, // opcode 0x26 MOVsnd
- { NULL }, // opcode 0x27
- { ExecuteMOVxx }, // opcode 0x28 MOVqq
- { ExecuteLOADSP }, // opcode 0x29 LOADSP SP1, R2
- { ExecuteSTORESP }, // opcode 0x2A STORESP R1, SP2
- { ExecutePUSH }, // opcode 0x2B PUSH {@}R1 [imm16]
- { ExecutePOP }, // opcode 0x2C POP {@}R1 [imm16]
- { ExecuteCMPI }, // opcode 0x2D CMPIEQ
- { ExecuteCMPI }, // opcode 0x2E CMPILTE
- { ExecuteCMPI }, // opcode 0x2F CMPIGTE
- { ExecuteCMPI }, // opcode 0x30 CMPIULTE
- { ExecuteCMPI }, // opcode 0x31 CMPIUGTE
- { ExecuteMOVxx }, // opcode 0x32 MOVN
- { ExecuteMOVxx }, // opcode 0x33 MOVND
- { NULL }, // opcode 0x34
- { ExecutePUSHn }, // opcode 0x35
- { ExecutePOPn }, // opcode 0x36
- { ExecuteMOVI }, // opcode 0x37 - mov immediate data
- { ExecuteMOVIn }, // opcode 0x38 - mov immediate natural
- { ExecuteMOVREL }, // opcode 0x39 - move data relative to PC
- { NULL }, // opcode 0x3a
- { NULL }, // opcode 0x3b
- { NULL }, // opcode 0x3c
- { NULL }, // opcode 0x3d
- { NULL }, // opcode 0x3e
- { NULL } // opcode 0x3f
+ { ExecuteMOVxx }, // opcode 0x1D MOVBW
+ { ExecuteMOVxx }, // opcode 0x1E MOVWW
+ { ExecuteMOVxx }, // opcode 0x1F MOVDW
+ { ExecuteMOVxx }, // opcode 0x20 MOVQW
+ { ExecuteMOVxx }, // opcode 0x21 MOVBD
+ { ExecuteMOVxx }, // opcode 0x22 MOVWD
+ { ExecuteMOVxx }, // opcode 0x23 MOVDD
+ { ExecuteMOVxx }, // opcode 0x24 MOVQD
+ { ExecuteMOVsnw }, // opcode 0x25 MOVsnw
+ { ExecuteMOVsnd }, // opcode 0x26 MOVsnd
+ { NULL }, // opcode 0x27
+ { ExecuteMOVxx }, // opcode 0x28 MOVqq
+ { ExecuteLOADSP }, // opcode 0x29 LOADSP SP1, R2
+ { ExecuteSTORESP }, // opcode 0x2A STORESP R1, SP2
+ { ExecutePUSH }, // opcode 0x2B PUSH {@}R1 [imm16]
+ { ExecutePOP }, // opcode 0x2C POP {@}R1 [imm16]
+ { ExecuteCMPI }, // opcode 0x2D CMPIEQ
+ { ExecuteCMPI }, // opcode 0x2E CMPILTE
+ { ExecuteCMPI }, // opcode 0x2F CMPIGTE
+ { ExecuteCMPI }, // opcode 0x30 CMPIULTE
+ { ExecuteCMPI }, // opcode 0x31 CMPIUGTE
+ { ExecuteMOVxx }, // opcode 0x32 MOVN
+ { ExecuteMOVxx }, // opcode 0x33 MOVND
+ { NULL }, // opcode 0x34
+ { ExecutePUSHn }, // opcode 0x35
+ { ExecutePOPn }, // opcode 0x36
+ { ExecuteMOVI }, // opcode 0x37 - mov immediate data
+ { ExecuteMOVIn }, // opcode 0x38 - mov immediate natural
+ { ExecuteMOVREL }, // opcode 0x39 - move data relative to PC
+ { NULL }, // opcode 0x3a
+ { NULL }, // opcode 0x3b
+ { NULL }, // opcode 0x3c
+ { NULL }, // opcode 0x3d
+ { NULL }, // opcode 0x3e
+ { NULL } // opcode 0x3f
};
//
// Length of JMP instructions, depending on upper two bits of opcode.
//
-CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 };
+CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 };
/**
Given a pointer to a new VM context, execute one or more instructions. This
@@ -1356,9 +1358,9 @@ CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 }; EFI_STATUS
EFIAPI
EbcExecuteInstructions (
- IN EFI_EBC_VM_TEST_PROTOCOL *This,
- IN VM_CONTEXT *VmPtr,
- IN OUT UINTN *InstructionCount
+ IN EFI_EBC_VM_TEST_PROTOCOL *This,
+ IN VM_CONTEXT *VmPtr,
+ IN OUT UINTN *InstructionCount
)
{
UINTN ExecFunc;
@@ -1383,8 +1385,8 @@ EbcExecuteInstructions ( // call it if it's not null.
//
while (InstructionsLeft != 0) {
- ExecFunc = (UINTN) mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
- if (ExecFunc == (UINTN) NULL) {
+ ExecFunc = (UINTN)mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
+ if (ExecFunc == (UINTN)NULL) {
EbcDebugSignalException (EXCEPT_EBC_INVALID_OPCODE, EXCEPTION_FLAG_FATAL, VmPtr);
return EFI_UNSUPPORTED;
} else {
@@ -1403,7 +1405,6 @@ EbcExecuteInstructions ( return Status;
}
-
/**
Execute an EBC image from an entry point or from a published protocol.
@@ -1415,7 +1416,7 @@ EbcExecuteInstructions ( **/
EFI_STATUS
EbcExecute (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINTN ExecFunc;
@@ -1431,24 +1432,25 @@ EbcExecute ( //
// Make sure the magic value has been put on the stack before we got here.
//
- if (*VmPtr->StackMagicPtr != (UINTN) VM_STACK_KEY_VALUE) {
+ if (*VmPtr->StackMagicPtr != (UINTN)VM_STACK_KEY_VALUE) {
StackCorrupted = 1;
}
- VmPtr->FramePtr = (VOID *) ((UINT8 *) (UINTN) VmPtr->Gpr[0] + 8);
+ VmPtr->FramePtr = (VOID *)((UINT8 *)(UINTN)VmPtr->Gpr[0] + 8);
//
// Try to get the debug support for EBC
//
DEBUG_CODE_BEGIN ();
- Status = gBS->LocateProtocol (
- &gEfiEbcSimpleDebuggerProtocolGuid,
- NULL,
- (VOID **) &EbcSimpleDebugger
- );
- if (EFI_ERROR (Status)) {
- EbcSimpleDebugger = NULL;
- }
+ Status = gBS->LocateProtocol (
+ &gEfiEbcSimpleDebuggerProtocolGuid,
+ NULL,
+ (VOID **)&EbcSimpleDebugger
+ );
+ if (EFI_ERROR (Status)) {
+ EbcSimpleDebugger = NULL;
+ }
+
DEBUG_CODE_END ();
//
@@ -1456,7 +1458,7 @@ EbcExecute ( // can print out the location of the exception relative to the entry point,
// which could then be used in a disassembly listing to find the problem.
//
- VmPtr->EntryPoint = (VOID *) VmPtr->Ip;
+ VmPtr->EntryPoint = (VOID *)VmPtr->Ip;
//
// We'll wait for this flag to know when we're done. The RET
@@ -1468,17 +1470,18 @@ EbcExecute ( // If we've found a simple debugger protocol, call it
//
DEBUG_CODE_BEGIN ();
- if (EbcSimpleDebugger != NULL) {
- EbcSimpleDebugger->Debugger (EbcSimpleDebugger, VmPtr);
- }
+ if (EbcSimpleDebugger != NULL) {
+ EbcSimpleDebugger->Debugger (EbcSimpleDebugger, VmPtr);
+ }
+
DEBUG_CODE_END ();
//
// Use the opcode bits to index into the opcode dispatch table. If the
// function pointer is null then generate an exception.
//
- ExecFunc = (UINTN) mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
- if (ExecFunc == (UINTN) NULL) {
+ ExecFunc = (UINTN)mVmOpcodeTable[(*VmPtr->Ip & OPCODE_M_OPCODE)].ExecuteFunction;
+ if (ExecFunc == (UINTN)NULL) {
EbcDebugSignalException (EXCEPT_EBC_INVALID_OPCODE, EXCEPTION_FLAG_FATAL, VmPtr);
Status = EFI_UNSUPPORTED;
goto Done;
@@ -1505,26 +1508,27 @@ EbcExecute ( if (VMFLAG_ISSET (VmPtr, VMFLAGS_STEP)) {
EbcDebugSignalException (EXCEPT_EBC_STEP, EXCEPTION_FLAG_NONE, VmPtr);
}
+
//
// Make sure stack has not been corrupted. Only report it once though.
//
- if ((StackCorrupted == 0) && (*VmPtr->StackMagicPtr != (UINTN) VM_STACK_KEY_VALUE)) {
+ if ((StackCorrupted == 0) && (*VmPtr->StackMagicPtr != (UINTN)VM_STACK_KEY_VALUE)) {
EbcDebugSignalException (EXCEPT_EBC_STACK_FAULT, EXCEPTION_FLAG_FATAL, VmPtr);
StackCorrupted = 1;
}
- if ((StackCorrupted == 0) && ((UINT64)VmPtr->Gpr[0] <= (UINT64)(UINTN) VmPtr->StackTop)) {
+
+ if ((StackCorrupted == 0) && ((UINT64)VmPtr->Gpr[0] <= (UINT64)(UINTN)VmPtr->StackTop)) {
EbcDebugSignalException (EXCEPT_EBC_STACK_FAULT, EXCEPTION_FLAG_FATAL, VmPtr);
StackCorrupted = 1;
}
}
Done:
- mVmPtr = NULL;
+ mVmPtr = NULL;
return Status;
}
-
/**
Execute the MOVxx instructions.
@@ -1548,7 +1552,7 @@ Done: **/
EFI_STATUS
ExecuteMOVxx (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -1565,7 +1569,7 @@ ExecuteMOVxx ( UINTN Source;
Opcode = GETOPCODE (VmPtr);
- OpcMasked = (UINT8) (Opcode & OPCODE_M_OPCODE);
+ OpcMasked = (UINT8)(Opcode & OPCODE_M_OPCODE);
//
// Get the operands byte so we can get R1 and R2
@@ -1575,9 +1579,9 @@ ExecuteMOVxx ( //
// Assume no indexes
//
- Index64Op1 = 0;
- Index64Op2 = 0;
- Data64 = 0;
+ Index64Op1 = 0;
+ Index64Op2 = 0;
+ Data64 = 0;
//
// Determine if we have an index/immediate data. Base instruction size
@@ -1594,30 +1598,30 @@ ExecuteMOVxx ( // Get one or both index values.
//
if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
- Index16 = VmReadIndex16 (VmPtr, 2);
- Index64Op1 = (INT64) Index16;
- Size += sizeof (UINT16);
+ Index16 = VmReadIndex16 (VmPtr, 2);
+ Index64Op1 = (INT64)Index16;
+ Size += sizeof (UINT16);
}
if ((Opcode & OPCODE_M_IMMED_OP2) != 0) {
- Index16 = VmReadIndex16 (VmPtr, Size);
- Index64Op2 = (INT64) Index16;
- Size += sizeof (UINT16);
+ Index16 = VmReadIndex16 (VmPtr, Size);
+ Index64Op2 = (INT64)Index16;
+ Size += sizeof (UINT16);
}
} else if ((OpcMasked <= OPCODE_MOVQD) || (OpcMasked == OPCODE_MOVND)) {
//
// MOVBD, MOVWD, MOVDD, MOVQD, and MOVND have 32-bit immediate index
//
if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
- Index32 = VmReadIndex32 (VmPtr, 2);
- Index64Op1 = (INT64) Index32;
- Size += sizeof (UINT32);
+ Index32 = VmReadIndex32 (VmPtr, 2);
+ Index64Op1 = (INT64)Index32;
+ Size += sizeof (UINT32);
}
if ((Opcode & OPCODE_M_IMMED_OP2) != 0) {
- Index32 = VmReadIndex32 (VmPtr, Size);
- Index64Op2 = (INT64) Index32;
- Size += sizeof (UINT32);
+ Index32 = VmReadIndex32 (VmPtr, Size);
+ Index64Op2 = (INT64)Index32;
+ Size += sizeof (UINT32);
}
} else if (OpcMasked == OPCODE_MOVQQ) {
//
@@ -1625,12 +1629,12 @@ ExecuteMOVxx ( //
if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
Index64Op1 = VmReadIndex64 (VmPtr, 2);
- Size += sizeof (UINT64);
+ Size += sizeof (UINT64);
}
if ((Opcode & OPCODE_M_IMMED_OP2) != 0) {
Index64Op2 = VmReadIndex64 (VmPtr, Size);
- Size += sizeof (UINT64);
+ Size += sizeof (UINT64);
}
} else {
//
@@ -1644,25 +1648,26 @@ ExecuteMOVxx ( return EFI_UNSUPPORTED;
}
}
+
//
// Determine the size of the move, and create a mask for it so we can
// clear unused bits.
//
if ((OpcMasked == OPCODE_MOVBW) || (OpcMasked == OPCODE_MOVBD)) {
- MoveSize = DATA_SIZE_8;
- DataMask = 0xFF;
+ MoveSize = DATA_SIZE_8;
+ DataMask = 0xFF;
} else if ((OpcMasked == OPCODE_MOVWW) || (OpcMasked == OPCODE_MOVWD)) {
- MoveSize = DATA_SIZE_16;
- DataMask = 0xFFFF;
+ MoveSize = DATA_SIZE_16;
+ DataMask = 0xFFFF;
} else if ((OpcMasked == OPCODE_MOVDW) || (OpcMasked == OPCODE_MOVDD)) {
- MoveSize = DATA_SIZE_32;
- DataMask = 0xFFFFFFFF;
+ MoveSize = DATA_SIZE_32;
+ DataMask = 0xFFFFFFFF;
} else if ((OpcMasked == OPCODE_MOVQW) || (OpcMasked == OPCODE_MOVQD) || (OpcMasked == OPCODE_MOVQQ)) {
- MoveSize = DATA_SIZE_64;
- DataMask = (UINT64)~0;
+ MoveSize = DATA_SIZE_64;
+ DataMask = (UINT64) ~0;
} else if ((OpcMasked == OPCODE_MOVNW) || (OpcMasked == OPCODE_MOVND)) {
- MoveSize = DATA_SIZE_N;
- DataMask = (UINT64)~0 >> (64 - 8 * sizeof (UINTN));
+ MoveSize = DATA_SIZE_N;
+ DataMask = (UINT64) ~0 >> (64 - 8 * sizeof (UINTN));
} else {
//
// We were dispatched to this function and we don't recognize the opcode
@@ -1670,6 +1675,7 @@ ExecuteMOVxx ( EbcDebugSignalException (EXCEPT_EBC_UNDEFINED, EXCEPTION_FLAG_FATAL, VmPtr);
return EFI_UNSUPPORTED;
}
+
//
// Now get the source address
//
@@ -1677,43 +1683,43 @@ ExecuteMOVxx ( //
// Indirect form @R2. Compute address of operand2
//
- Source = (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
+ Source = (UINTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
//
// Now get the data from the source. Always 0-extend and let the compiler
// sign-extend where required.
//
switch (MoveSize) {
- case DATA_SIZE_8:
- Data64 = (UINT64) (UINT8) VmReadMem8 (VmPtr, Source);
- break;
-
- case DATA_SIZE_16:
- Data64 = (UINT64) (UINT16) VmReadMem16 (VmPtr, Source);
- break;
-
- case DATA_SIZE_32:
- Data64 = (UINT64) (UINT32) VmReadMem32 (VmPtr, Source);
- break;
-
- case DATA_SIZE_64:
- Data64 = (UINT64) VmReadMem64 (VmPtr, Source);
- break;
-
- case DATA_SIZE_N:
- Data64 = (UINT64) (UINTN) VmReadMemN (VmPtr, Source);
- break;
-
- default:
- //
- // not reached
- //
- break;
+ case DATA_SIZE_8:
+ Data64 = (UINT64)(UINT8)VmReadMem8 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_16:
+ Data64 = (UINT64)(UINT16)VmReadMem16 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_32:
+ Data64 = (UINT64)(UINT32)VmReadMem32 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_64:
+ Data64 = (UINT64)VmReadMem64 (VmPtr, Source);
+ break;
+
+ case DATA_SIZE_N:
+ Data64 = (UINT64)(UINTN)VmReadMemN (VmPtr, Source);
+ break;
+
+ default:
+ //
+ // not reached
+ //
+ break;
}
} else {
//
// Not indirect source: MOVxx {@}Rx, Ry [Index]
//
- Data64 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
+ Data64 = (UINT64)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);
//
// Did Operand2 have an index? If so, treat as two signed values since
// indexes are signed values.
@@ -1737,11 +1743,13 @@ ExecuteMOVxx ( (Index64Op2 > 0) &&
(OPERAND1_REGNUM (Operands) == 0) &&
(OPERAND1_INDIRECT (Operands))
- ) {
- Data64 = (UINT64) ConvertStackAddr (VmPtr, (UINTN) (INT64) Data64);
+ )
+ {
+ Data64 = (UINT64)ConvertStackAddr (VmPtr, (UINTN)(INT64)Data64);
}
}
}
+
//
// Now write it back
//
@@ -1749,36 +1757,36 @@ ExecuteMOVxx ( //
// Reuse the Source variable to now be dest.
//
- Source = (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index64Op1);
+ Source = (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index64Op1);
//
// Do the write based on the size
//
switch (MoveSize) {
- case DATA_SIZE_8:
- VmWriteMem8 (VmPtr, Source, (UINT8) Data64);
- break;
-
- case DATA_SIZE_16:
- VmWriteMem16 (VmPtr, Source, (UINT16) Data64);
- break;
-
- case DATA_SIZE_32:
- VmWriteMem32 (VmPtr, Source, (UINT32) Data64);
- break;
-
- case DATA_SIZE_64:
- VmWriteMem64 (VmPtr, Source, Data64);
- break;
-
- case DATA_SIZE_N:
- VmWriteMemN (VmPtr, Source, (UINTN) Data64);
- break;
-
- default:
- //
- // not reached
- //
- break;
+ case DATA_SIZE_8:
+ VmWriteMem8 (VmPtr, Source, (UINT8)Data64);
+ break;
+
+ case DATA_SIZE_16:
+ VmWriteMem16 (VmPtr, Source, (UINT16)Data64);
+ break;
+
+ case DATA_SIZE_32:
+ VmWriteMem32 (VmPtr, Source, (UINT32)Data64);
+ break;
+
+ case DATA_SIZE_64:
+ VmWriteMem64 (VmPtr, Source, Data64);
+ break;
+
+ case DATA_SIZE_N:
+ VmWriteMemN (VmPtr, Source, (UINTN)Data64);
+ break;
+
+ default:
+ //
+ // not reached
+ //
+ break;
}
} else {
//
@@ -1793,12 +1801,14 @@ ExecuteMOVxx ( );
return EFI_UNSUPPORTED;
}
+
//
// Direct storage in register. Clear unused bits and store back to
// register.
//
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Data64 & DataMask;
}
+
//
// Advance the instruction pointer
//
@@ -1806,7 +1816,6 @@ ExecuteMOVxx ( return EFI_SUCCESS;
}
-
/**
Execute the EBC BREAK instruction.
@@ -1817,7 +1826,7 @@ ExecuteMOVxx ( **/
EFI_STATUS
ExecuteBREAK (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
EFI_STATUS Status;
@@ -1827,91 +1836,92 @@ ExecuteBREAK ( UINT64 U64EbcEntryPoint;
INT32 Offset;
- Thunk = NULL;
+ Thunk = NULL;
Operands = GETOPERANDS (VmPtr);
switch (Operands) {
- //
- // Runaway program break. Generate an exception and terminate
- //
- case 0:
- EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
- break;
-
- //
- // Get VM version -- return VM revision number in R7
- //
- case 1:
//
- // Bits:
- // 63-17 = 0
- // 16-8 = Major version
- // 7-0 = Minor version
+ // Runaway program break. Generate an exception and terminate
//
- VmPtr->Gpr[7] = GetVmVersion ();
- break;
+ case 0:
+ EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
+ break;
- //
- // Debugger breakpoint
- //
- case 3:
- VmPtr->StopFlags |= STOPFLAG_BREAKPOINT;
//
- // See if someone has registered a handler
+ // Get VM version -- return VM revision number in R7
//
- EbcDebugSignalException (
- EXCEPT_EBC_BREAKPOINT,
- EXCEPTION_FLAG_NONE,
- VmPtr
- );
- break;
-
- //
- // System call, which there are none, so NOP it.
- //
- case 4:
- break;
+ case 1:
+ //
+ // Bits:
+ // 63-17 = 0
+ // 16-8 = Major version
+ // 7-0 = Minor version
+ //
+ VmPtr->Gpr[7] = GetVmVersion ();
+ break;
- //
- // Create a thunk for EBC code. R7 points to a 32-bit (in a 64-bit slot)
- // "offset from self" pointer to the EBC entry point.
- // After we're done, *(UINT64 *)R7 will be the address of the new thunk.
- //
- case 5:
- Offset = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->Gpr[7]);
- U64EbcEntryPoint = (UINT64) (VmPtr->Gpr[7] + Offset + 4);
- EbcEntryPoint = (VOID *) (UINTN) U64EbcEntryPoint;
+ //
+ // Debugger breakpoint
+ //
+ case 3:
+ VmPtr->StopFlags |= STOPFLAG_BREAKPOINT;
+ //
+ // See if someone has registered a handler
+ //
+ EbcDebugSignalException (
+ EXCEPT_EBC_BREAKPOINT,
+ EXCEPTION_FLAG_NONE,
+ VmPtr
+ );
+ break;
//
- // Now create a new thunk
+ // System call, which there are none, so NOP it.
//
- Status = EbcCreateThunks (VmPtr->ImageHandle, EbcEntryPoint, &Thunk, 0);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ case 4:
+ break;
//
- // Finally replace the EBC entry point memory with the thunk address
+ // Create a thunk for EBC code. R7 points to a 32-bit (in a 64-bit slot)
+ // "offset from self" pointer to the EBC entry point.
+ // After we're done, *(UINT64 *)R7 will be the address of the new thunk.
//
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[7], (UINT64) (UINTN) Thunk);
- break;
+ case 5:
+ Offset = (INT32)VmReadMem32 (VmPtr, (UINTN)VmPtr->Gpr[7]);
+ U64EbcEntryPoint = (UINT64)(VmPtr->Gpr[7] + Offset + 4);
+ EbcEntryPoint = (VOID *)(UINTN)U64EbcEntryPoint;
+
+ //
+ // Now create a new thunk
+ //
+ Status = EbcCreateThunks (VmPtr->ImageHandle, EbcEntryPoint, &Thunk, 0);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Finally replace the EBC entry point memory with the thunk address
+ //
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[7], (UINT64)(UINTN)Thunk);
+ break;
- //
- // Compiler setting version per value in R7
- //
- case 6:
- VmPtr->CompilerVersion = (UINT32) VmPtr->Gpr[7];
//
- // Check compiler version against VM version?
+ // Compiler setting version per value in R7
//
- break;
+ case 6:
+ VmPtr->CompilerVersion = (UINT32)VmPtr->Gpr[7];
+ //
+ // Check compiler version against VM version?
+ //
+ break;
- //
- // Unhandled break code. Signal exception.
- //
- default:
- EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
- break;
+ //
+ // Unhandled break code. Signal exception.
+ //
+ default:
+ EbcDebugSignalException (EXCEPT_EBC_BAD_BREAK, EXCEPTION_FLAG_FATAL, VmPtr);
+ break;
}
+
//
// Advance IP
//
@@ -1919,7 +1929,6 @@ ExecuteBREAK ( return EFI_SUCCESS;
}
-
/**
Execute the JMP instruction.
@@ -1947,7 +1956,7 @@ ExecuteBREAK ( **/
EFI_STATUS
ExecuteJMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -1972,8 +1981,8 @@ ExecuteJMP ( // Decode instruction conditions
// If we haven't met the condition, then simply advance the IP and return.
//
- CompareSet = (UINT8) (((Operand & JMP_M_CS) != 0) ? 1 : 0);
- ConditionFlag = (UINT8) VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
+ CompareSet = (UINT8)(((Operand & JMP_M_CS) != 0) ? 1 : 0);
+ ConditionFlag = (UINT8)VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
if ((Operand & CONDITION_M_CONDITIONAL) != 0) {
if (CompareSet != ConditionFlag) {
EbcDebuggerHookJMPStart (VmPtr);
@@ -1982,6 +1991,7 @@ ExecuteJMP ( return EFI_SUCCESS;
}
}
+
//
// Check for 64-bit form and do it right away since it's the most
// straight-forward form.
@@ -1999,12 +2009,13 @@ ExecuteJMP ( );
return EFI_UNSUPPORTED;
}
+
//
// 64-bit immediate data is full address. Read the immediate data,
// check for alignment, and jump absolute.
//
- Data64 = (UINT64) VmReadImmed64 (VmPtr, 2);
- if (!IS_ALIGNED ((UINTN) Data64, sizeof (UINT16))) {
+ Data64 = (UINT64)VmReadImmed64 (VmPtr, 2);
+ if (!IS_ALIGNED ((UINTN)Data64, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2019,14 +2030,16 @@ ExecuteJMP ( //
EbcDebuggerHookJMPStart (VmPtr);
if ((Operand & JMP_M_RELATIVE) != 0) {
- VmPtr->Ip += (UINTN) Data64 + Size;
+ VmPtr->Ip += (UINTN)Data64 + Size;
} else {
- VmPtr->Ip = (VMIP) (UINTN) Data64;
+ VmPtr->Ip = (VMIP)(UINTN)Data64;
}
+
EbcDebuggerHookJMPEnd (VmPtr);
return EFI_SUCCESS;
}
+
//
// 32-bit forms:
// Get the index if there is one. May be either an index, or an immediate
@@ -2043,14 +2056,16 @@ ExecuteJMP ( } else {
Index32 = 0;
}
+
//
// Get the register data. If R == 0, then special case where it's ignored.
//
if (OPERAND1_REGNUM (Operand) == 0) {
Data64 = 0;
} else {
- Data64 = (UINT64) OPERAND1_REGDATA (VmPtr, Operand);
+ Data64 = (UINT64)OPERAND1_REGDATA (VmPtr, Operand);
}
+
//
// Decode the forms
//
@@ -2058,8 +2073,8 @@ ExecuteJMP ( //
// Form: JMP32 @Rx {Index32}
//
- Addr = VmReadMemN (VmPtr, (UINTN) Data64 + Index32);
- if (!IS_ALIGNED ((UINTN) Addr, sizeof (UINT16))) {
+ Addr = VmReadMemN (VmPtr, (UINTN)Data64 + Index32);
+ if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2071,18 +2086,18 @@ ExecuteJMP ( EbcDebuggerHookJMPStart (VmPtr);
if ((Operand & JMP_M_RELATIVE) != 0) {
- VmPtr->Ip += (UINTN) Addr + Size;
+ VmPtr->Ip += (UINTN)Addr + Size;
} else {
- VmPtr->Ip = (VMIP) Addr;
+ VmPtr->Ip = (VMIP)Addr;
}
- EbcDebuggerHookJMPEnd (VmPtr);
+ EbcDebuggerHookJMPEnd (VmPtr);
} else {
//
// Form: JMP32 Rx {Immed32}
//
- Addr = (UINTN) (Data64 + Index32);
- if (!IS_ALIGNED ((UINTN) Addr, sizeof (UINT16))) {
+ Addr = (UINTN)(Data64 + Index32);
+ if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2094,18 +2109,17 @@ ExecuteJMP ( EbcDebuggerHookJMPStart (VmPtr);
if ((Operand & JMP_M_RELATIVE) != 0) {
- VmPtr->Ip += (UINTN) Addr + Size;
+ VmPtr->Ip += (UINTN)Addr + Size;
} else {
- VmPtr->Ip = (VMIP) Addr;
+ VmPtr->Ip = (VMIP)Addr;
}
- EbcDebuggerHookJMPEnd (VmPtr);
+ EbcDebuggerHookJMPEnd (VmPtr);
}
return EFI_SUCCESS;
}
-
/**
Execute the EBC JMP8 instruction.
@@ -2119,20 +2133,20 @@ ExecuteJMP ( **/
EFI_STATUS
ExecuteJMP8 (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 ConditionFlag;
- UINT8 CompareSet;
- INT8 Offset;
+ UINT8 Opcode;
+ UINT8 ConditionFlag;
+ UINT8 CompareSet;
+ INT8 Offset;
//
// Decode instruction.
//
Opcode = GETOPCODE (VmPtr);
- CompareSet = (UINT8) (((Opcode & JMP_M_CS) != 0) ? 1 : 0);
- ConditionFlag = (UINT8) VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
+ CompareSet = (UINT8)(((Opcode & JMP_M_CS) != 0) ? 1 : 0);
+ ConditionFlag = (UINT8)VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
//
// If we haven't met the condition, then simply advance the IP and return
@@ -2145,6 +2159,7 @@ ExecuteJMP8 ( return EFI_SUCCESS;
}
}
+
//
// Get the offset from the instruction stream. It's relative to the
// following instruction, and divided by 2.
@@ -2159,7 +2174,6 @@ ExecuteJMP8 ( return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVI.
@@ -2183,7 +2197,7 @@ ExecuteJMP8 ( **/
EFI_STATUS
ExecuteMOVI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2197,8 +2211,8 @@ ExecuteMOVI ( //
// Get the opcode and operands byte so we can get R1 and R2
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the index (16-bit) if present
@@ -2210,18 +2224,19 @@ ExecuteMOVI ( Index16 = 0;
Size = 2;
}
+
//
// Extract the immediate data. Sign-extend always.
//
if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
- ImmData64 = (INT64) (INT16) VmReadImmed16 (VmPtr, Size);
- Size += 2;
+ ImmData64 = (INT64)(INT16)VmReadImmed16 (VmPtr, Size);
+ Size += 2;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
- ImmData64 = (INT64) (INT32) VmReadImmed32 (VmPtr, Size);
- Size += 4;
+ ImmData64 = (INT64)(INT32)VmReadImmed32 (VmPtr, Size);
+ Size += 4;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
- ImmData64 = (INT64) VmReadImmed64 (VmPtr, Size);
- Size += 8;
+ ImmData64 = (INT64)VmReadImmed64 (VmPtr, Size);
+ Size += 8;
} else {
//
// Invalid encoding
@@ -2233,6 +2248,7 @@ ExecuteMOVI ( );
return EFI_UNSUPPORTED;
}
+
//
// Now write back the result
//
@@ -2248,6 +2264,7 @@ ExecuteMOVI ( );
return EFI_UNSUPPORTED;
}
+
//
// Writing directly to a register. Clear unused bits.
//
@@ -2258,7 +2275,7 @@ ExecuteMOVI ( } else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH32) {
Mask64 = 0x00000000FFFFFFFF;
} else {
- Mask64 = (UINT64)~0;
+ Mask64 = (UINT64) ~0;
}
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = ImmData64 & Mask64;
@@ -2266,17 +2283,18 @@ ExecuteMOVI ( //
// Get the address then write back based on size of the move
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH8) {
- VmWriteMem8 (VmPtr, (UINTN) Op1, (UINT8) ImmData64);
+ VmWriteMem8 (VmPtr, (UINTN)Op1, (UINT8)ImmData64);
} else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH16) {
- VmWriteMem16 (VmPtr, (UINTN) Op1, (UINT16) ImmData64);
+ VmWriteMem16 (VmPtr, (UINTN)Op1, (UINT16)ImmData64);
} else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH32) {
- VmWriteMem32 (VmPtr, (UINTN) Op1, (UINT32) ImmData64);
+ VmWriteMem32 (VmPtr, (UINTN)Op1, (UINT32)ImmData64);
} else {
- VmWriteMem64 (VmPtr, (UINTN) Op1, (UINT64) ImmData64);
+ VmWriteMem64 (VmPtr, (UINTN)Op1, (UINT64)ImmData64);
}
}
+
//
// Advance the instruction pointer
//
@@ -2284,7 +2302,6 @@ ExecuteMOVI ( return EFI_SUCCESS;
}
-
/**
Execute the EBC MOV immediate natural. This instruction moves an immediate
index value into a register or memory location.
@@ -2301,7 +2318,7 @@ ExecuteMOVI ( **/
EFI_STATUS
ExecuteMOVIn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2316,8 +2333,8 @@ ExecuteMOVIn ( //
// Get the opcode and operands byte so we can get R1 and R2
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the operand1 index (16-bit) if present
@@ -2329,20 +2346,21 @@ ExecuteMOVIn ( Index16 = 0;
Size = 2;
}
+
//
// Extract the immediate data and convert to a 64-bit index.
//
if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
- ImmedIndex16 = VmReadIndex16 (VmPtr, Size);
- ImmedIndex64 = (INT64) ImmedIndex16;
- Size += 2;
+ ImmedIndex16 = VmReadIndex16 (VmPtr, Size);
+ ImmedIndex64 = (INT64)ImmedIndex16;
+ Size += 2;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
- ImmedIndex32 = VmReadIndex32 (VmPtr, Size);
- ImmedIndex64 = (INT64) ImmedIndex32;
- Size += 4;
+ ImmedIndex32 = VmReadIndex32 (VmPtr, Size);
+ ImmedIndex64 = (INT64)ImmedIndex32;
+ Size += 4;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
ImmedIndex64 = VmReadIndex64 (VmPtr, Size);
- Size += 8;
+ Size += 8;
} else {
//
// Invalid encoding
@@ -2354,6 +2372,7 @@ ExecuteMOVIn ( );
return EFI_UNSUPPORTED;
}
+
//
// Now write back the result
//
@@ -2376,9 +2395,10 @@ ExecuteMOVIn ( //
// Get the address
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
- VmWriteMemN (VmPtr, (UINTN) Op1, (UINTN)(INTN) ImmedIndex64);
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ VmWriteMemN (VmPtr, (UINTN)Op1, (UINTN)(INTN)ImmedIndex64);
}
+
//
// Advance the instruction pointer
//
@@ -2386,7 +2406,6 @@ ExecuteMOVIn ( return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVREL instruction.
Dest <- Ip + ImmData
@@ -2403,7 +2422,7 @@ ExecuteMOVIn ( **/
EFI_STATUS
ExecuteMOVREL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2417,8 +2436,8 @@ ExecuteMOVREL ( //
// Get the opcode and operands byte so we can get R1 and R2
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the Operand 1 index (16-bit) if present
@@ -2430,18 +2449,19 @@ ExecuteMOVREL ( Index16 = 0;
Size = 2;
}
+
//
// Get the immediate data.
//
if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
- ImmData64 = (INT64) VmReadImmed16 (VmPtr, Size);
- Size += 2;
+ ImmData64 = (INT64)VmReadImmed16 (VmPtr, Size);
+ Size += 2;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
- ImmData64 = (INT64) VmReadImmed32 (VmPtr, Size);
- Size += 4;
+ ImmData64 = (INT64)VmReadImmed32 (VmPtr, Size);
+ Size += 4;
} else if ((Opcode & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
ImmData64 = VmReadImmed64 (VmPtr, Size);
- Size += 8;
+ Size += 8;
} else {
//
// Invalid encoding
@@ -2453,10 +2473,11 @@ ExecuteMOVREL ( );
return EFI_UNSUPPORTED;
}
+
//
// Compute the value and write back the result
//
- Op2 = (UINT64) ((INT64) ((UINT64) (UINTN) VmPtr->Ip) + (INT64) ImmData64 + Size);
+ Op2 = (UINT64)((INT64)((UINT64)(UINTN)VmPtr->Ip) + (INT64)ImmData64 + Size);
if (!OPERAND1_INDIRECT (Operands)) {
//
// Check for illegal combination of operand1 direct with immediate data
@@ -2470,16 +2491,17 @@ ExecuteMOVREL ( return EFI_UNSUPPORTED;
}
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (VM_REGISTER) Op2;
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (VM_REGISTER)Op2;
} else {
//
// Get the address = [Rx] + Index16
// Write back the result. Always a natural size write, since
// we're talking addresses here.
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
- VmWriteMemN (VmPtr, (UINTN) Op1, (UINTN) Op2);
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ VmWriteMemN (VmPtr, (UINTN)Op1, (UINTN)Op2);
}
+
//
// Advance the instruction pointer
//
@@ -2487,7 +2509,6 @@ ExecuteMOVREL ( return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVsnw instruction. This instruction loads a signed
natural value from memory or register to another memory or register. On
@@ -2509,7 +2530,7 @@ ExecuteMOVREL ( **/
EFI_STATUS
ExecuteMOVsnw (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2522,16 +2543,16 @@ ExecuteMOVsnw ( //
// Get the opcode and operand bytes
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
- Op1Index = Op2Index = 0;
+ Op1Index = Op2Index = 0;
//
// Get the indexes if present.
//
Size = 2;
- if ((Opcode & OPCODE_M_IMMED_OP1) !=0) {
+ if ((Opcode & OPCODE_M_IMMED_OP1) != 0) {
if (OPERAND1_INDIRECT (Operands)) {
Op1Index = VmReadIndex16 (VmPtr, 2);
} else {
@@ -2558,21 +2579,24 @@ ExecuteMOVsnw ( Size += sizeof (UINT16);
}
+
//
// Get the data from the source.
//
Op2 = (UINT64)(INT64)(INTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
if (OPERAND2_INDIRECT (Operands)) {
- Op2 = (UINT64)(INT64)(INTN)VmReadMemN (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)(INT64)(INTN)VmReadMemN (VmPtr, (UINTN)Op2);
}
+
//
// Now write back the result.
//
if (!OPERAND1_INDIRECT (Operands)) {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;
} else {
- VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);
+ VmWriteMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN)Op2);
}
+
//
// Advance the instruction pointer
//
@@ -2580,7 +2604,6 @@ ExecuteMOVsnw ( return EFI_SUCCESS;
}
-
/**
Execute the EBC MOVsnw instruction. This instruction loads a signed
natural value from memory or register to another memory or register. On
@@ -2602,7 +2625,7 @@ ExecuteMOVsnw ( **/
EFI_STATUS
ExecuteMOVsnd (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2615,10 +2638,10 @@ ExecuteMOVsnd ( //
// Get the opcode and operand bytes
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
- Op1Index = Op2Index = 0;
+ Op1Index = Op2Index = 0;
//
// Get the indexes if present.
@@ -2651,21 +2674,24 @@ ExecuteMOVsnd ( Size += sizeof (UINT32);
}
+
//
// Get the data from the source.
//
Op2 = (UINT64)(INT64)(INTN)(INT64)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
if (OPERAND2_INDIRECT (Operands)) {
- Op2 = (UINT64)(INT64)(INTN)(INT64)VmReadMemN (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)(INT64)(INTN)(INT64)VmReadMemN (VmPtr, (UINTN)Op2);
}
+
//
// Now write back the result.
//
if (!OPERAND1_INDIRECT (Operands)) {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;
} else {
- VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);
+ VmWriteMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN)Op2);
}
+
//
// Advance the instruction pointer
//
@@ -2673,7 +2699,6 @@ ExecuteMOVsnd ( return EFI_SUCCESS;
}
-
/**
Execute the EBC PUSHn instruction
@@ -2687,19 +2712,19 @@ ExecuteMOVsnd ( **/
EFI_STATUS
ExecutePUSHn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 Operands;
- INT16 Index16;
- UINTN DataN;
+ UINT8 Opcode;
+ UINT8 Operands;
+ INT16 Index16;
+ UINTN DataN;
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get index if present
@@ -2713,26 +2738,27 @@ ExecutePUSHn ( VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Get the data to push
//
if (OPERAND1_INDIRECT (Operands)) {
- DataN = VmReadMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
+ DataN = VmReadMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
} else {
- DataN = (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16);
+ DataN = (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16);
}
+
//
// Adjust the stack down.
//
VmPtr->Gpr[0] -= sizeof (UINTN);
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], DataN);
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], DataN);
return EFI_SUCCESS;
}
-
/**
Execute the EBC PUSH instruction.
@@ -2746,7 +2772,7 @@ ExecutePUSHn ( **/
EFI_STATUS
ExecutePUSH (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2758,8 +2784,8 @@ ExecutePUSH ( //
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get immediate index if present, then advance the IP.
//
@@ -2772,43 +2798,45 @@ ExecutePUSH ( VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Get the data to push
//
if ((Opcode & PUSHPOP_M_64) != 0) {
if (OPERAND1_INDIRECT (Operands)) {
- Data64 = VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
+ Data64 = VmReadMem64 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
} else {
- Data64 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ Data64 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
}
+
//
// Adjust the stack down, then write back the data
//
VmPtr->Gpr[0] -= sizeof (UINT64);
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], Data64);
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], Data64);
} else {
//
// 32-bit data
//
if (OPERAND1_INDIRECT (Operands)) {
- Data32 = VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
+ Data32 = VmReadMem32 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
} else {
- Data32 = (UINT32) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
+ Data32 = (UINT32)VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
}
+
//
// Adjust the stack down and write the data
//
VmPtr->Gpr[0] -= sizeof (UINT32);
- VmWriteMem32 (VmPtr, (UINTN) VmPtr->Gpr[0], Data32);
+ VmWriteMem32 (VmPtr, (UINTN)VmPtr->Gpr[0], Data32);
}
return EFI_SUCCESS;
}
-
/**
Execute the EBC POPn instruction.
@@ -2822,19 +2850,19 @@ ExecutePUSH ( **/
EFI_STATUS
ExecutePOPn (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 Operands;
- INT16 Index16;
- UINTN DataN;
+ UINT8 Opcode;
+ UINT8 Operands;
+ INT16 Index16;
+ UINTN DataN;
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get immediate data if present, and advance the IP
//
@@ -2847,27 +2875,27 @@ ExecutePOPn ( VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Read the data off the stack, then adjust the stack pointer
//
- DataN = VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);
+ DataN = VmReadMemN (VmPtr, (UINTN)VmPtr->Gpr[0]);
VmPtr->Gpr[0] += sizeof (UINTN);
//
// Do the write-back
//
if (OPERAND1_INDIRECT (Operands)) {
- VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);
+ VmWriteMemN (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);
} else {
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) (UINTN) (DataN + Index16);
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64)(UINT64)(UINTN)(DataN + Index16);
}
return EFI_SUCCESS;
}
-
/**
Execute the EBC POP instruction.
@@ -2881,7 +2909,7 @@ ExecutePOPn ( **/
EFI_STATUS
ExecutePOP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -2893,8 +2921,8 @@ ExecutePOP ( //
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get immediate data if present, and advance the IP.
//
@@ -2907,9 +2935,10 @@ ExecutePOP ( VmPtr->Ip += 4;
} else {
- Index16 = 0;
+ Index16 = 0;
VmPtr->Ip += 2;
}
+
//
// Get the data off the stack, then write it to the appropriate location
//
@@ -2917,13 +2946,13 @@ ExecutePOP ( //
// Read the data off the stack, then adjust the stack pointer
//
- Data64 = VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);
+ Data64 = VmReadMem64 (VmPtr, (UINTN)VmPtr->Gpr[0]);
VmPtr->Gpr[0] += sizeof (UINT64);
//
// Do the write-back
//
if (OPERAND1_INDIRECT (Operands)) {
- VmWriteMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data64);
+ VmWriteMem64 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data64);
} else {
VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Data64 + Index16;
}
@@ -2931,22 +2960,21 @@ ExecutePOP ( //
// 32-bit pop. Read it off the stack and adjust the stack pointer
//
- Data32 = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->Gpr[0]);
+ Data32 = (INT32)VmReadMem32 (VmPtr, (UINTN)VmPtr->Gpr[0]);
VmPtr->Gpr[0] += sizeof (UINT32);
//
// Do the write-back
//
if (OPERAND1_INDIRECT (Operands)) {
- VmWriteMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data32);
+ VmWriteMem32 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data32);
} else {
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) Data32 + Index16;
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64)Data32 + Index16;
}
}
return EFI_SUCCESS;
}
-
/**
Implements the EBC CALL instruction.
@@ -2965,21 +2993,21 @@ ExecutePOP ( **/
EFI_STATUS
ExecuteCALL (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Opcode;
- UINT8 Operands;
- INT32 Immed32;
- UINT8 Size;
- INT64 Immed64;
- VOID *FramePtr;
+ UINT8 Opcode;
+ UINT8 Operands;
+ INT32 Immed32;
+ UINT8 Size;
+ INT64 Immed64;
+ VOID *FramePtr;
//
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
if ((Operands & OPERAND_M_NATIVE_CALL) != 0) {
EbcDebuggerHookCALLEXStart (VmPtr);
@@ -2990,10 +3018,10 @@ ExecuteCALL ( //
// Assign these as well to avoid compiler warnings
//
- Immed64 = 0;
- Immed32 = 0;
+ Immed64 = 0;
+ Immed32 = 0;
- FramePtr = VmPtr->FramePtr;
+ FramePtr = VmPtr->FramePtr;
//
// Determine the instruction size, and get immediate data if present
//
@@ -3016,17 +3044,19 @@ ExecuteCALL ( } else {
Size = 2;
}
+
//
// If it's a call to EBC, adjust the stack pointer down 16 bytes and
// put our return address and frame pointer on the VM stack.
//
if ((Operands & OPERAND_M_NATIVE_CALL) == 0) {
VmPtr->Gpr[0] -= 8;
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);
- VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];
- VmPtr->Gpr[0] -= 8;
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], (UINTN)FramePtr);
+ VmPtr->FramePtr = (VOID *)(UINTN)VmPtr->Gpr[0];
+ VmPtr->Gpr[0] -= 8;
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], (UINT64)(UINTN)(VmPtr->Ip + Size));
}
+
//
// If 64-bit data, then absolute jump only
//
@@ -3035,12 +3065,12 @@ ExecuteCALL ( // Native or EBC call?
//
if ((Operands & OPERAND_M_NATIVE_CALL) == 0) {
- VmPtr->Ip = (VMIP) (UINTN) Immed64;
+ VmPtr->Ip = (VMIP)(UINTN)Immed64;
} else {
//
// Call external function, get the return value, and advance the IP
//
- EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->Gpr[0], FramePtr, Size);
+ EbcLLCALLEX (VmPtr, (UINTN)Immed64, (UINTN)VmPtr->Gpr[0], FramePtr, Size);
}
} else {
//
@@ -3049,16 +3079,18 @@ ExecuteCALL ( // Compiler should take care of upper bits if 32-bit machine.
//
if (OPERAND1_REGNUM (Operands) != 0) {
- Immed64 = (UINT64) (UINTN) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Immed64 = (UINT64)(UINTN)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
}
+
//
// Get final address
//
if (OPERAND1_INDIRECT (Operands)) {
- Immed64 = (INT64) (UINT64) (UINTN) VmReadMemN (VmPtr, (UINTN) (Immed64 + Immed32));
+ Immed64 = (INT64)(UINT64)(UINTN)VmReadMemN (VmPtr, (UINTN)(Immed64 + Immed32));
} else {
Immed64 += Immed32;
}
+
//
// Now determine if external call, and then if relative or absolute
//
@@ -3070,20 +3102,20 @@ ExecuteCALL ( if ((Operands & OPERAND_M_RELATIVE_ADDR) != 0) {
VmPtr->Ip += Immed64 + Size;
} else {
- VmPtr->Ip = (VMIP) (UINTN) Immed64;
+ VmPtr->Ip = (VMIP)(UINTN)Immed64;
}
} else {
//
// Native call. Relative or absolute?
//
if ((Operands & OPERAND_M_RELATIVE_ADDR) != 0) {
- EbcLLCALLEX (VmPtr, (UINTN) (Immed64 + VmPtr->Ip + Size), (UINTN) VmPtr->Gpr[0], FramePtr, Size);
+ EbcLLCALLEX (VmPtr, (UINTN)(Immed64 + VmPtr->Ip + Size), (UINTN)VmPtr->Gpr[0], FramePtr, Size);
} else {
if ((VmPtr->StopFlags & STOPFLAG_BREAK_ON_CALLEX) != 0) {
CpuBreakpoint ();
}
- EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->Gpr[0], FramePtr, Size);
+ EbcLLCALLEX (VmPtr, (UINTN)Immed64, (UINTN)VmPtr->Gpr[0], FramePtr, Size);
}
}
}
@@ -3097,7 +3129,6 @@ ExecuteCALL ( return EFI_SUCCESS;
}
-
/**
Execute the EBC RET instruction.
@@ -3111,46 +3142,44 @@ ExecuteCALL ( **/
EFI_STATUS
ExecuteRET (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
-
EbcDebuggerHookRETStart (VmPtr);
//
// If we're at the top of the stack, then simply set the done
// flag and return
//
- if (VmPtr->StackRetAddr == (UINT64) VmPtr->Gpr[0]) {
+ if (VmPtr->StackRetAddr == (UINT64)VmPtr->Gpr[0]) {
VmPtr->StopFlags |= STOPFLAG_APP_DONE;
} else {
//
// Pull the return address off the VM app's stack and set the IP
// to it
//
- if (!IS_ALIGNED ((UINTN) VmPtr->Gpr[0], sizeof (UINT16))) {
+ if (!IS_ALIGNED ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
VmPtr
);
}
+
//
// Restore the IP and frame pointer from the stack
//
- VmPtr->Ip = (VMIP) (UINTN) VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);
- VmPtr->Gpr[0] += 8;
- VmPtr->FramePtr = (VOID *) VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);
- VmPtr->Gpr[0] += 8;
+ VmPtr->Ip = (VMIP)(UINTN)VmReadMem64 (VmPtr, (UINTN)VmPtr->Gpr[0]);
+ VmPtr->Gpr[0] += 8;
+ VmPtr->FramePtr = (VOID *)VmReadMemN (VmPtr, (UINTN)VmPtr->Gpr[0]);
+ VmPtr->Gpr[0] += 8;
}
-
EbcDebuggerHookRETEnd (VmPtr);
return EFI_SUCCESS;
}
-
/**
Execute the EBC CMP instruction.
@@ -3165,7 +3194,7 @@ ExecuteRET ( **/
EFI_STATUS
ExecuteCMP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -3179,8 +3208,8 @@ ExecuteCMP ( //
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get the register data we're going to compare to
//
@@ -3200,21 +3229,23 @@ ExecuteCMP ( Index16 = 0;
Size = 2;
}
+
//
// Now get Op2
//
if (OPERAND2_INDIRECT (Operands)) {
if ((Opcode & OPCODE_M_64BIT) != 0) {
- Op2 = (INT64) VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16));
+ Op2 = (INT64)VmReadMem64 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16));
} else {
//
// 32-bit operations. 0-extend the values for all cases.
//
- Op2 = (INT64) (UINT64) ((UINT32) VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16)));
+ Op2 = (INT64)(UINT64)((UINT32)VmReadMem32 (VmPtr, (UINTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16)));
}
} else {
Op2 = VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;
}
+
//
// Now do the compare
//
@@ -3224,78 +3255,89 @@ ExecuteCMP ( // 64-bit compares
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPEQ:
- if (Op1 == Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPEQ:
+ if (Op1 == Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPLTE:
- if (Op1 <= Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPGTE:
- if (Op1 >= Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPLTE:
+ if (Op1 <= Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPULTE:
- if ((UINT64) Op1 <= (UINT64) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPUGTE:
- if ((UINT64) Op1 >= (UINT64) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPGTE:
+ if (Op1 >= Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPULTE:
+ if ((UINT64)Op1 <= (UINT64)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPUGTE:
+ if ((UINT64)Op1 >= (UINT64)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
} else {
//
// 32-bit compares
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPEQ:
- if ((INT32) Op1 == (INT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPEQ:
+ if ((INT32)Op1 == (INT32)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPLTE:
- if ((INT32) Op1 <= (INT32) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPGTE:
- if ((INT32) Op1 >= (INT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPLTE:
+ if ((INT32)Op1 <= (INT32)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPULTE:
- if ((UINT32) Op1 <= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPUGTE:
- if ((UINT32) Op1 >= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPGTE:
+ if ((INT32)Op1 >= (INT32)Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPULTE:
+ if ((UINT32)Op1 <= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPUGTE:
+ if ((UINT32)Op1 >= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
}
+
//
// Now set the flag accordingly for the comparison
//
@@ -3304,6 +3346,7 @@ ExecuteCMP ( } else {
VMFLAG_CLEAR (VmPtr, (UINT64)VMFLAGS_CC);
}
+
//
// Advance the IP
//
@@ -3311,7 +3354,6 @@ ExecuteCMP ( return EFI_SUCCESS;
}
-
/**
Execute the EBC CMPI instruction
@@ -3326,7 +3368,7 @@ ExecuteCMP ( **/
EFI_STATUS
ExecuteCMPI (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
UINT8 Opcode;
@@ -3340,8 +3382,8 @@ ExecuteCMPI ( //
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Get operand1 index if present
@@ -3349,22 +3391,23 @@ ExecuteCMPI ( Size = 2;
if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
Index16 = VmReadIndex16 (VmPtr, 2);
- Size += 2;
+ Size += 2;
} else {
Index16 = 0;
}
+
//
// Get operand1 data we're going to compare to
//
- Op1 = (INT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Op1 = (INT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
if (OPERAND1_INDIRECT (Operands)) {
//
// Indirect operand1. Fetch 32 or 64-bit value based on compare size.
//
if ((Opcode & OPCODE_M_CMPI64) != 0) {
- Op1 = (INT64) VmReadMem64 (VmPtr, (UINTN) Op1 + Index16);
+ Op1 = (INT64)VmReadMem64 (VmPtr, (UINTN)Op1 + Index16);
} else {
- Op1 = (INT64) VmReadMem32 (VmPtr, (UINTN) Op1 + Index16);
+ Op1 = (INT64)VmReadMem32 (VmPtr, (UINTN)Op1 + Index16);
}
} else {
//
@@ -3381,19 +3424,21 @@ ExecuteCMPI ( return EFI_UNSUPPORTED;
}
}
+
//
// Get immediate data -- 16- or 32-bit sign extended
//
if ((Opcode & OPCODE_M_CMPI32_DATA) != 0) {
- Op2 = (INT64) VmReadImmed32 (VmPtr, Size);
+ Op2 = (INT64)VmReadImmed32 (VmPtr, Size);
Size += 4;
} else {
//
// 16-bit immediate data. Sign extend always.
//
- Op2 = (INT64) ((INT16) VmReadImmed16 (VmPtr, Size));
+ Op2 = (INT64)((INT16)VmReadImmed16 (VmPtr, Size));
Size += 2;
}
+
//
// Now do the compare
//
@@ -3403,78 +3448,89 @@ ExecuteCMPI ( // 64 bit comparison
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPIEQ:
- if (Op1 == (INT64) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIEQ:
+ if (Op1 == (INT64)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPILTE:
- if (Op1 <= (INT64) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIGTE:
- if (Op1 >= (INT64) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPILTE:
+ if (Op1 <= (INT64)Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPIULTE:
- if ((UINT64) Op1 <= (UINT64) ((UINT32) Op2)) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIUGTE:
- if ((UINT64) Op1 >= (UINT64) ((UINT32) Op2)) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIGTE:
+ if (Op1 >= (INT64)Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPIULTE:
+ if ((UINT64)Op1 <= (UINT64)((UINT32)Op2)) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPIUGTE:
+ if ((UINT64)Op1 >= (UINT64)((UINT32)Op2)) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
} else {
//
// 32-bit comparisons
//
switch (Opcode & OPCODE_M_OPCODE) {
- case OPCODE_CMPIEQ:
- if ((INT32) Op1 == Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIEQ:
+ if ((INT32)Op1 == Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPILTE:
- if ((INT32) Op1 <= Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIGTE:
- if ((INT32) Op1 >= Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPILTE:
+ if ((INT32)Op1 <= Op2) {
+ Flag = 1;
+ }
- case OPCODE_CMPIULTE:
- if ((UINT32) Op1 <= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ break;
- case OPCODE_CMPIUGTE:
- if ((UINT32) Op1 >= (UINT32) Op2) {
- Flag = 1;
- }
- break;
+ case OPCODE_CMPIGTE:
+ if ((INT32)Op1 >= Op2) {
+ Flag = 1;
+ }
- default:
- ASSERT (0);
+ break;
+
+ case OPCODE_CMPIULTE:
+ if ((UINT32)Op1 <= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ case OPCODE_CMPIUGTE:
+ if ((UINT32)Op1 >= (UINT32)Op2) {
+ Flag = 1;
+ }
+
+ break;
+
+ default:
+ ASSERT (0);
}
}
+
//
// Now set the flag accordingly for the comparison
//
@@ -3483,6 +3539,7 @@ ExecuteCMPI ( } else {
VMFLAG_CLEAR (VmPtr, (UINT64)VMFLAGS_CC);
}
+
//
// Advance the IP
//
@@ -3490,7 +3547,6 @@ ExecuteCMPI ( return EFI_SUCCESS;
}
-
/**
Execute the EBC NOT instruction.s
@@ -3506,15 +3562,14 @@ ExecuteCMPI ( **/
UINT64
ExecuteNOT (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return ~Op2;
}
-
/**
Execute the EBC NEG instruction.
@@ -3530,15 +3585,14 @@ ExecuteNOT ( **/
UINT64
ExecuteNEG (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return ~Op2 + 1;
}
-
/**
Execute the EBC ADD instruction.
@@ -3554,15 +3608,14 @@ ExecuteNEG ( **/
UINT64
ExecuteADD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 + Op2;
}
-
/**
Execute the EBC SUB instruction.
@@ -3578,19 +3631,18 @@ ExecuteADD ( **/
UINT64
ExecuteSUB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
- return (UINT64) ((INT64) ((INT64) Op1 - (INT64) Op2));
+ return (UINT64)((INT64)((INT64)Op1 - (INT64)Op2));
} else {
- return (UINT64) ((INT64) ((INT32) ((INT32) Op1 - (INT32) Op2)));
+ return (UINT64)((INT64)((INT32)((INT32)Op1 - (INT32)Op2)));
}
}
-
/**
Execute the EBC MUL instruction.
@@ -3606,19 +3658,18 @@ ExecuteSUB ( **/
UINT64
ExecuteMUL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultS64x64 ((INT64)Op1, (INT64)Op2);
} else {
- return (UINT64) ((INT64) ((INT32) ((INT32) Op1 * (INT32) Op2)));
+ return (UINT64)((INT64)((INT32)((INT32)Op1 * (INT32)Op2)));
}
}
-
/**
Execute the EBC MULU instruction
@@ -3634,19 +3685,18 @@ ExecuteMUL ( **/
UINT64
ExecuteMULU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return MultU64x64 (Op1, Op2);
} else {
- return (UINT64) ((UINT32) ((UINT32) Op1 * (UINT32) Op2));
+ return (UINT64)((UINT32)((UINT32)Op1 * (UINT32)Op2));
}
}
-
/**
Execute the EBC DIV instruction.
@@ -3662,12 +3712,12 @@ ExecuteMULU ( **/
UINT64
ExecuteDIV (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT64 Remainder;
+ INT64 Remainder;
//
// Check for divide-by-0
@@ -3682,14 +3732,13 @@ ExecuteDIV ( return 0;
} else {
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
- return (UINT64) (DivS64x64Remainder (Op1, Op2, &Remainder));
+ return (UINT64)(DivS64x64Remainder (Op1, Op2, &Remainder));
} else {
- return (UINT64) ((INT64) ((INT32) Op1 / (INT32) Op2));
+ return (UINT64)((INT64)((INT32)Op1 / (INT32)Op2));
}
}
}
-
/**
Execute the EBC DIVU instruction
@@ -3705,9 +3754,9 @@ ExecuteDIV ( **/
UINT64
ExecuteDIVU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
UINT64 Remainder;
@@ -3727,14 +3776,13 @@ ExecuteDIVU ( // Get the destination register
//
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
- return (UINT64) (DivU64x64Remainder (Op1, Op2, &Remainder));
+ return (UINT64)(DivU64x64Remainder (Op1, Op2, &Remainder));
} else {
- return (UINT64) ((UINT32) Op1 / (UINT32) Op2);
+ return (UINT64)((UINT32)Op1 / (UINT32)Op2);
}
}
}
-
/**
Execute the EBC MOD instruction.
@@ -3750,12 +3798,12 @@ ExecuteDIVU ( **/
UINT64
ExecuteMOD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT64 Remainder;
+ INT64 Remainder;
//
// Check for divide-by-0
@@ -3773,7 +3821,6 @@ ExecuteMOD ( }
}
-
/**
Execute the EBC MODU instruction.
@@ -3789,9 +3836,9 @@ ExecuteMOD ( **/
UINT64
ExecuteMODU (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
UINT64 Remainder;
@@ -3812,7 +3859,6 @@ ExecuteMODU ( }
}
-
/**
Execute the EBC AND instruction.
@@ -3828,15 +3874,14 @@ ExecuteMODU ( **/
UINT64
ExecuteAND (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 & Op2;
}
-
/**
Execute the EBC OR instruction.
@@ -3852,15 +3897,14 @@ ExecuteAND ( **/
UINT64
ExecuteOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 | Op2;
}
-
/**
Execute the EBC XOR instruction.
@@ -3876,15 +3920,14 @@ ExecuteOR ( **/
UINT64
ExecuteXOR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
return Op1 ^ Op2;
}
-
/**
Execute the EBC SHL shift left instruction.
@@ -3900,19 +3943,18 @@ ExecuteXOR ( **/
UINT64
ExecuteSHL (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return LShiftU64 (Op1, (UINTN)Op2);
} else {
- return (UINT64) ((UINT32) ((UINT32) Op1 << (UINT32) Op2));
+ return (UINT64)((UINT32)((UINT32)Op1 << (UINT32)Op2));
}
}
-
/**
Execute the EBC SHR instruction.
@@ -3928,19 +3970,18 @@ ExecuteSHL ( **/
UINT64
ExecuteSHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return RShiftU64 (Op1, (UINTN)Op2);
} else {
- return (UINT64) ((UINT32) Op1 >> (UINT32) Op2);
+ return (UINT64)((UINT32)Op1 >> (UINT32)Op2);
}
}
-
/**
Execute the EBC ASHR instruction.
@@ -3956,19 +3997,18 @@ ExecuteSHR ( **/
UINT64
ExecuteASHR (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {
return ARShiftU64 (Op1, (UINTN)Op2);
} else {
- return (UINT64) ((INT64) ((INT32) Op1 >> (UINT32) Op2));
+ return (UINT64)((INT64)((INT32)Op1 >> (UINT32)Op2));
}
}
-
/**
Execute the EBC EXTNDB instruction to sign-extend a byte value.
@@ -3984,24 +4024,24 @@ ExecuteASHR ( **/
UINT64
ExecuteEXTNDB (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT8 Data8;
- INT64 Data64;
+ INT8 Data8;
+ INT64 Data64;
+
//
// Convert to byte, then return as 64-bit signed value to let compiler
// sign-extend the value
//
- Data8 = (INT8) Op2;
- Data64 = (INT64) Data8;
+ Data8 = (INT8)Op2;
+ Data64 = (INT64)Data8;
- return (UINT64) Data64;
+ return (UINT64)Data64;
}
-
/**
Execute the EBC EXTNDW instruction to sign-extend a 16-bit value.
@@ -4017,22 +4057,24 @@ ExecuteEXTNDB ( **/
UINT64
ExecuteEXTNDW (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT16 Data16;
- INT64 Data64;
+ INT16 Data16;
+ INT64 Data64;
+
//
// Convert to word, then return as 64-bit signed value to let compiler
// sign-extend the value
//
- Data16 = (INT16) Op2;
- Data64 = (INT64) Data16;
+ Data16 = (INT16)Op2;
+ Data64 = (INT64)Data16;
- return (UINT64) Data64;
+ return (UINT64)Data64;
}
+
//
// Execute the EBC EXTNDD instruction.
//
@@ -4057,24 +4099,24 @@ ExecuteEXTNDW ( **/
UINT64
ExecuteEXTNDD (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Op1,
- IN UINT64 Op2
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Op1,
+ IN UINT64 Op2
)
{
- INT32 Data32;
- INT64 Data64;
+ INT32 Data32;
+ INT64 Data64;
+
//
// Convert to 32-bit value, then return as 64-bit signed value to let compiler
// sign-extend the value
//
- Data32 = (INT32) Op2;
- Data64 = (INT64) Data32;
+ Data32 = (INT32)Op2;
+ Data64 = (INT64)Data32;
- return (UINT64) Data64;
+ return (UINT64)Data64;
}
-
/**
Execute all the EBC signed data manipulation instructions.
Since the EBC data manipulation instructions all have the same basic form,
@@ -4094,7 +4136,7 @@ ExecuteEXTNDD ( **/
EFI_STATUS
ExecuteSignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
//
@@ -4104,7 +4146,6 @@ ExecuteSignedDataManip ( return ExecuteDataManip (VmPtr, TRUE);
}
-
/**
Execute all the EBC unsigned data manipulation instructions.
Since the EBC data manipulation instructions all have the same basic form,
@@ -4124,7 +4165,7 @@ ExecuteSignedDataManip ( **/
EFI_STATUS
ExecuteUnsignedDataManip (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
//
@@ -4134,7 +4175,6 @@ ExecuteUnsignedDataManip ( return ExecuteDataManip (VmPtr, FALSE);
}
-
/**
Execute all the EBC data manipulation instructions.
Since the EBC data manipulation instructions all have the same basic form,
@@ -4155,8 +4195,8 @@ ExecuteUnsignedDataManip ( **/
EFI_STATUS
ExecuteDataManip (
- IN VM_CONTEXT *VmPtr,
- IN BOOLEAN IsSignedOp
+ IN VM_CONTEXT *VmPtr,
+ IN BOOLEAN IsSignedOp
)
{
UINT8 Opcode;
@@ -4170,8 +4210,8 @@ ExecuteDataManip ( //
// Get opcode and operands
//
- Opcode = GETOPCODE (VmPtr);
- Operands = GETOPERANDS (VmPtr);
+ Opcode = GETOPCODE (VmPtr);
+ Operands = GETOPERANDS (VmPtr);
//
// Determine if we have immediate data by the opcode
@@ -4191,65 +4231,69 @@ ExecuteDataManip ( Index16 = 0;
Size = 2;
}
+
//
// Now get operand2 (source). It's of format {@}R2 {Index16|Immed16}
//
- Op2 = (UINT64) VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;
+ Op2 = (UINT64)VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;
if (OPERAND2_INDIRECT (Operands)) {
//
// Indirect form: @R2 Index16. Fetch as 32- or 64-bit data
//
if ((Opcode & DATAMANIP_M_64) != 0) {
- Op2 = VmReadMem64 (VmPtr, (UINTN) Op2);
+ Op2 = VmReadMem64 (VmPtr, (UINTN)Op2);
} else {
//
// Read as signed value where appropriate.
//
if (IsSignedOp) {
- Op2 = (UINT64) (INT64) ((INT32) VmReadMem32 (VmPtr, (UINTN) Op2));
+ Op2 = (UINT64)(INT64)((INT32)VmReadMem32 (VmPtr, (UINTN)Op2));
} else {
- Op2 = (UINT64) VmReadMem32 (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)VmReadMem32 (VmPtr, (UINTN)Op2);
}
}
} else {
if ((Opcode & DATAMANIP_M_64) == 0) {
if (IsSignedOp) {
- Op2 = (UINT64) (INT64) ((INT32) Op2);
+ Op2 = (UINT64)(INT64)((INT32)Op2);
} else {
- Op2 = (UINT64) ((UINT32) Op2);
+ Op2 = (UINT64)((UINT32)Op2);
}
}
}
+
//
// Get operand1 (destination and sometimes also an actual operand)
// of form {@}R1
//
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
if (OPERAND1_INDIRECT (Operands)) {
if ((Opcode & DATAMANIP_M_64) != 0) {
- Op1 = VmReadMem64 (VmPtr, (UINTN) Op1);
+ Op1 = VmReadMem64 (VmPtr, (UINTN)Op1);
} else {
if (IsSignedOp) {
- Op1 = (UINT64) (INT64) ((INT32) VmReadMem32 (VmPtr, (UINTN) Op1));
+ Op1 = (UINT64)(INT64)((INT32)VmReadMem32 (VmPtr, (UINTN)Op1));
} else {
- Op1 = (UINT64) VmReadMem32 (VmPtr, (UINTN) Op1);
+ Op1 = (UINT64)VmReadMem32 (VmPtr, (UINTN)Op1);
}
}
} else {
if ((Opcode & DATAMANIP_M_64) == 0) {
if (IsSignedOp) {
- Op1 = (UINT64) (INT64) ((INT32) Op1);
+ Op1 = (UINT64)(INT64)((INT32)Op1);
} else {
- Op1 = (UINT64) ((UINT32) Op1);
+ Op1 = (UINT64)((UINT32)Op1);
}
}
}
+
//
// Dispatch to the computation function
//
DataManipDispatchTableIndex = (Opcode & OPCODE_M_OPCODE) - OPCODE_NOT;
if ((DataManipDispatchTableIndex < 0) ||
- (DataManipDispatchTableIndex >= ARRAY_SIZE (mDataManipDispatchTable))) {
+ (DataManipDispatchTableIndex >= ARRAY_SIZE (mDataManipDispatchTable)))
+ {
EbcDebugSignalException (
EXCEPT_EBC_INVALID_OPCODE,
EXCEPTION_FLAG_ERROR,
@@ -4263,15 +4307,16 @@ ExecuteDataManip ( } else {
Op2 = mDataManipDispatchTable[DataManipDispatchTableIndex](VmPtr, Op1, Op2);
}
+
//
// Write back the result.
//
if (OPERAND1_INDIRECT (Operands)) {
- Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
+ Op1 = (UINT64)VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
if ((Opcode & DATAMANIP_M_64) != 0) {
- VmWriteMem64 (VmPtr, (UINTN) Op1, Op2);
+ VmWriteMem64 (VmPtr, (UINTN)Op1, Op2);
} else {
- VmWriteMem32 (VmPtr, (UINTN) Op1, (UINT32) Op2);
+ VmWriteMem32 (VmPtr, (UINTN)Op1, (UINT32)Op2);
}
} else {
//
@@ -4283,6 +4328,7 @@ ExecuteDataManip ( VmPtr->Gpr[OPERAND1_REGNUM (Operands)] &= 0xFFFFFFFF;
}
}
+
//
// Advance the instruction pointer
//
@@ -4290,7 +4336,6 @@ ExecuteDataManip ( return EFI_SUCCESS;
}
-
/**
Execute the EBC LOADSP instruction.
@@ -4305,10 +4350,10 @@ ExecuteDataManip ( **/
EFI_STATUS
ExecuteLOADSP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Operands;
+ UINT8 Operands;
//
// Get the operands
@@ -4319,32 +4364,31 @@ ExecuteLOADSP ( // Do the operation
//
switch (OPERAND1_REGNUM (Operands)) {
- //
- // Set flags
- //
- case 0:
//
- // Spec states that this instruction will not modify reserved bits in
- // the flags register.
+ // Set flags
//
- VmPtr->Flags = (VmPtr->Flags &~VMFLAGS_ALL_VALID) | (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] & VMFLAGS_ALL_VALID);
- break;
+ case 0:
+ //
+ // Spec states that this instruction will not modify reserved bits in
+ // the flags register.
+ //
+ VmPtr->Flags = (VmPtr->Flags &~VMFLAGS_ALL_VALID) | (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] & VMFLAGS_ALL_VALID);
+ break;
- default:
- EbcDebugSignalException (
- EXCEPT_EBC_INSTRUCTION_ENCODING,
- EXCEPTION_FLAG_WARNING,
- VmPtr
- );
- VmPtr->Ip += 2;
- return EFI_UNSUPPORTED;
+ default:
+ EbcDebugSignalException (
+ EXCEPT_EBC_INSTRUCTION_ENCODING,
+ EXCEPTION_FLAG_WARNING,
+ VmPtr
+ );
+ VmPtr->Ip += 2;
+ return EFI_UNSUPPORTED;
}
VmPtr->Ip += 2;
return EFI_SUCCESS;
}
-
/**
Execute the EBC STORESP instruction.
@@ -4359,10 +4403,10 @@ ExecuteLOADSP ( **/
EFI_STATUS
ExecuteSTORESP (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- UINT8 Operands;
+ UINT8 Operands;
//
// Get the operands
@@ -4373,39 +4417,38 @@ ExecuteSTORESP ( // Do the operation
//
switch (OPERAND2_REGNUM (Operands)) {
- //
- // Get flags
- //
- case 0:
//
- // Retrieve the value in the flags register, then clear reserved bits
+ // Get flags
//
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64) (VmPtr->Flags & VMFLAGS_ALL_VALID);
- break;
+ case 0:
+ //
+ // Retrieve the value in the flags register, then clear reserved bits
+ //
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64)(VmPtr->Flags & VMFLAGS_ALL_VALID);
+ break;
- //
- // Get IP -- address of following instruction
- //
- case 1:
- VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64) (UINTN) VmPtr->Ip + 2;
- break;
+ //
+ // Get IP -- address of following instruction
+ //
+ case 1:
+ VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64)(UINTN)VmPtr->Ip + 2;
+ break;
- default:
- EbcDebugSignalException (
- EXCEPT_EBC_INSTRUCTION_ENCODING,
- EXCEPTION_FLAG_WARNING,
- VmPtr
- );
- VmPtr->Ip += 2;
- return EFI_UNSUPPORTED;
- break;
+ default:
+ EbcDebugSignalException (
+ EXCEPT_EBC_INSTRUCTION_ENCODING,
+ EXCEPTION_FLAG_WARNING,
+ VmPtr
+ );
+ VmPtr->Ip += 2;
+ return EFI_UNSUPPORTED;
+ break;
}
VmPtr->Ip += 2;
return EFI_SUCCESS;
}
-
/**
Decode a 16-bit index to determine the offset. Given an index value:
@@ -4430,8 +4473,8 @@ ExecuteSTORESP ( **/
INT16
VmReadIndex16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
)
{
UINT16 Index;
@@ -4449,7 +4492,7 @@ VmReadIndex16 ( //
// Get the mask for NaturalUnits. First get the number of bits from the index.
//
- NBits = (INT16) ((Index & 0x7000) >> 12);
+ NBits = (INT16)((Index & 0x7000) >> 12);
//
// Scale it for 16-bit indexes
@@ -4459,19 +4502,19 @@ VmReadIndex16 ( //
// Now using the number of bits, create a mask.
//
- Mask = (INT16) ((INT16)~0 << NBits);
+ Mask = (INT16)((INT16) ~0 << NBits);
//
// Now using the mask, extract NaturalUnits from the lower bits of the index.
//
- NaturalUnits = (INT16) (Index &~Mask);
+ NaturalUnits = (INT16)(Index &~Mask);
//
// Now compute ConstUnits
//
- ConstUnits = (INT16) (((Index &~0xF000) & Mask) >> NBits);
+ ConstUnits = (INT16)(((Index &~0xF000) & Mask) >> NBits);
- Offset = (INT16) (NaturalUnits * sizeof (UINTN) + ConstUnits);
+ Offset = (INT16)(NaturalUnits * sizeof (UINTN) + ConstUnits);
//
// Now set the sign
@@ -4482,13 +4525,12 @@ VmReadIndex16 ( //
// Offset = -1 * Offset;
//
- Offset = (INT16) ((INT32) Offset * -1);
+ Offset = (INT16)((INT32)Offset * -1);
}
return Offset;
}
-
/**
Decode a 32-bit index to determine the offset.
@@ -4501,8 +4543,8 @@ VmReadIndex16 ( **/
INT32
VmReadIndex32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
)
{
UINT32 Index;
@@ -4527,7 +4569,7 @@ VmReadIndex32 ( //
// Now using the number of bits, create a mask.
//
- Mask = (INT32)~0 << NBits;
+ Mask = (INT32) ~0 << NBits;
//
// Now using the mask, extract NaturalUnits from the lower bits of the index.
@@ -4537,9 +4579,9 @@ VmReadIndex32 ( //
// Now compute ConstUnits
//
- ConstUnits = ((Index &~0xF0000000) & Mask) >> NBits;
+ ConstUnits = ((Index &~0xF0000000) & Mask) >> NBits;
- Offset = NaturalUnits * sizeof (UINTN) + ConstUnits;
+ Offset = NaturalUnits * sizeof (UINTN) + ConstUnits;
//
// Now set the sign
@@ -4551,7 +4593,6 @@ VmReadIndex32 ( return Offset;
}
-
/**
Decode a 64-bit index to determine the offset.
@@ -4564,8 +4605,8 @@ VmReadIndex32 ( **/
INT64
VmReadIndex64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 CodeOffset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 CodeOffset
)
{
UINT64 Index;
@@ -4590,7 +4631,7 @@ VmReadIndex64 ( //
// Now using the number of bits, create a mask.
//
- Mask = (LShiftU64 ((UINT64)~0, (UINTN)NBits));
+ Mask = (LShiftU64 ((UINT64) ~0, (UINTN)NBits));
//
// Now using the mask, extract NaturalUnits from the lower bits of the index.
@@ -4602,7 +4643,7 @@ VmReadIndex64 ( //
ConstUnits = ARShiftU64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN)NBits);
- Offset = MultU64x64 ((UINT64) NaturalUnits, sizeof (UINTN)) + ConstUnits;
+ Offset = MultU64x64 ((UINT64)NaturalUnits, sizeof (UINTN)) + ConstUnits;
//
// Now set the sign
@@ -4614,7 +4655,6 @@ VmReadIndex64 ( return Offset;
}
-
/**
Writes 8-bit data to memory address.
@@ -4640,16 +4680,16 @@ VmReadIndex64 ( **/
EFI_STATUS
VmWriteMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT8 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT8 Data
)
{
//
// Convert the address if it's in the stack gap
//
- Addr = ConvertStackAddr (VmPtr, Addr);
- *(UINT8 *) Addr = Data;
+ Addr = ConvertStackAddr (VmPtr, Addr);
+ *(UINT8 *)Addr = Data;
return EFI_SUCCESS;
}
@@ -4678,9 +4718,9 @@ VmWriteMem8 ( **/
EFI_STATUS
VmWriteMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT16 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT16 Data
)
{
EFI_STATUS Status;
@@ -4694,18 +4734,18 @@ VmWriteMem16 ( // Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT16))) {
- *(UINT16 *) Addr = Data;
+ *(UINT16 *)Addr = Data;
} else {
//
// Write as two bytes
//
MemoryFence ();
- if ((Status = VmWriteMem8 (VmPtr, Addr, (UINT8) Data)) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem8 (VmPtr, Addr, (UINT8)Data)) != EFI_SUCCESS) {
return Status;
}
MemoryFence ();
- if ((Status = VmWriteMem8 (VmPtr, Addr + 1, (UINT8) (Data >> 8))) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem8 (VmPtr, Addr + 1, (UINT8)(Data >> 8))) != EFI_SUCCESS) {
return Status;
}
@@ -4715,7 +4755,6 @@ VmWriteMem16 ( return EFI_SUCCESS;
}
-
/**
Writes 32-bit data to memory address.
@@ -4741,9 +4780,9 @@ VmWriteMem16 ( **/
EFI_STATUS
VmWriteMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT32 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT32 Data
)
{
EFI_STATUS Status;
@@ -4757,18 +4796,18 @@ VmWriteMem32 ( // Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT32))) {
- *(UINT32 *) Addr = Data;
+ *(UINT32 *)Addr = Data;
} else {
//
// Write as two words
//
MemoryFence ();
- if ((Status = VmWriteMem16 (VmPtr, Addr, (UINT16) Data)) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem16 (VmPtr, Addr, (UINT16)Data)) != EFI_SUCCESS) {
return Status;
}
MemoryFence ();
- if ((Status = VmWriteMem16 (VmPtr, Addr + sizeof (UINT16), (UINT16) (Data >> 16))) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem16 (VmPtr, Addr + sizeof (UINT16), (UINT16)(Data >> 16))) != EFI_SUCCESS) {
return Status;
}
@@ -4778,7 +4817,6 @@ VmWriteMem32 ( return EFI_SUCCESS;
}
-
/**
Writes 64-bit data to memory address.
@@ -4804,9 +4842,9 @@ VmWriteMem32 ( **/
EFI_STATUS
VmWriteMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT64 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT64 Data
)
{
EFI_STATUS Status;
@@ -4820,18 +4858,18 @@ VmWriteMem64 ( // Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT64))) {
- *(UINT64 *) Addr = Data;
+ *(UINT64 *)Addr = Data;
} else {
//
// Write as two 32-bit words
//
MemoryFence ();
- if ((Status = VmWriteMem32 (VmPtr, Addr, (UINT32) Data)) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem32 (VmPtr, Addr, (UINT32)Data)) != EFI_SUCCESS) {
return Status;
}
MemoryFence ();
- if ((Status = VmWriteMem32 (VmPtr, Addr + sizeof (UINT32), (UINT32) RShiftU64(Data, 32))) != EFI_SUCCESS) {
+ if ((Status = VmWriteMem32 (VmPtr, Addr + sizeof (UINT32), (UINT32)RShiftU64 (Data, 32))) != EFI_SUCCESS) {
return Status;
}
@@ -4841,7 +4879,6 @@ VmWriteMem64 ( return EFI_SUCCESS;
}
-
/**
Writes UINTN data to memory address.
@@ -4867,9 +4904,9 @@ VmWriteMem64 ( **/
EFI_STATUS
VmWriteMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINTN Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINTN Data
)
{
EFI_STATUS Status;
@@ -4886,20 +4923,19 @@ VmWriteMemN ( // Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINTN))) {
- *(UINTN *) Addr = Data;
+ *(UINTN *)Addr = Data;
} else {
for (Index = 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) {
MemoryFence ();
- Status = VmWriteMem32 (VmPtr, Addr + Index * sizeof (UINT32), (UINT32) Data);
+ Status = VmWriteMem32 (VmPtr, Addr + Index * sizeof (UINT32), (UINT32)Data);
MemoryFence ();
- Data = (UINTN) RShiftU64 ((UINT64)Data, 32);
+ Data = (UINTN)RShiftU64 ((UINT64)Data, 32);
}
}
return Status;
}
-
/**
Reads 8-bit immediate value at the offset.
@@ -4916,14 +4952,14 @@ VmWriteMemN ( **/
INT8
VmReadImmed8 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
//
// Simply return the data in flat memory space
//
- return * (INT8 *) (VmPtr->Ip + Offset);
+ return *(INT8 *)(VmPtr->Ip + Offset);
}
/**
@@ -4942,15 +4978,15 @@ VmReadImmed8 ( **/
INT16
VmReadImmed16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (INT16))) {
- return * (INT16 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) {
+ return *(INT16 *)(VmPtr->Ip + Offset);
} else {
//
// All code word reads should be aligned
@@ -4961,13 +4997,13 @@ VmReadImmed16 ( VmPtr
);
}
+
//
// Return unaligned data
//
- return (INT16) (*(UINT8 *) (VmPtr->Ip + Offset) + (*(UINT8 *) (VmPtr->Ip + Offset + 1) << 8));
+ return (INT16)(*(UINT8 *)(VmPtr->Ip + Offset) + (*(UINT8 *)(VmPtr->Ip + Offset + 1) << 8));
}
-
/**
Reads 32-bit immediate value at the offset.
@@ -4984,8 +5020,8 @@ VmReadImmed16 ( **/
INT32
VmReadImmed32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT32 Data;
@@ -4993,18 +5029,18 @@ VmReadImmed32 ( //
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT32))) {
- return * (INT32 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
+ return *(INT32 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data
//
- Data = (UINT32) VmReadCode16 (VmPtr, Offset);
+ Data = (UINT32)VmReadCode16 (VmPtr, Offset);
Data |= (UINT32)(VmReadCode16 (VmPtr, Offset + 2) << 16);
return Data;
}
-
/**
Reads 64-bit immediate value at the offset.
@@ -5021,8 +5057,8 @@ VmReadImmed32 ( **/
INT64
VmReadImmed64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT64 Data64;
@@ -5032,22 +5068,22 @@ VmReadImmed64 ( //
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT64))) {
- return * (UINT64 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
+ return *(UINT64 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data.
//
- Ptr = (UINT8 *) &Data64;
- Data32 = VmReadCode32 (VmPtr, Offset);
- *(UINT32 *) Ptr = Data32;
- Ptr += sizeof (Data32);
- Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
- *(UINT32 *) Ptr = Data32;
+ Ptr = (UINT8 *)&Data64;
+ Data32 = VmReadCode32 (VmPtr, Offset);
+ *(UINT32 *)Ptr = Data32;
+ Ptr += sizeof (Data32);
+ Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
+ *(UINT32 *)Ptr = Data32;
return Data64;
}
-
/**
Reads 16-bit unsigned data from the code stream.
@@ -5062,15 +5098,15 @@ VmReadImmed64 ( **/
UINT16
VmReadCode16 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT16))) {
- return * (UINT16 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) {
+ return *(UINT16 *)(VmPtr->Ip + Offset);
} else {
//
// All code word reads should be aligned
@@ -5081,13 +5117,13 @@ VmReadCode16 ( VmPtr
);
}
+
//
// Return unaligned data
//
- return (UINT16) (*(UINT8 *) (VmPtr->Ip + Offset) + (*(UINT8 *) (VmPtr->Ip + Offset + 1) << 8));
+ return (UINT16)(*(UINT8 *)(VmPtr->Ip + Offset) + (*(UINT8 *)(VmPtr->Ip + Offset + 1) << 8));
}
-
/**
Reads 32-bit unsigned data from the code stream.
@@ -5102,26 +5138,27 @@ VmReadCode16 ( **/
UINT32
VmReadCode32 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT32 Data;
+
//
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT32))) {
- return * (UINT32 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
+ return *(UINT32 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data
//
- Data = (UINT32) VmReadCode16 (VmPtr, Offset);
+ Data = (UINT32)VmReadCode16 (VmPtr, Offset);
Data |= (VmReadCode16 (VmPtr, Offset + 2) << 16);
return Data;
}
-
/**
Reads 64-bit unsigned data from the code stream.
@@ -5136,8 +5173,8 @@ VmReadCode32 ( **/
UINT64
VmReadCode64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT32 Offset
+ IN VM_CONTEXT *VmPtr,
+ IN UINT32 Offset
)
{
UINT64 Data64;
@@ -5147,22 +5184,22 @@ VmReadCode64 ( //
// Read direct if aligned
//
- if (IS_ALIGNED ((UINTN) VmPtr->Ip + Offset, sizeof (UINT64))) {
- return * (UINT64 *) (VmPtr->Ip + Offset);
+ if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
+ return *(UINT64 *)(VmPtr->Ip + Offset);
}
+
//
// Return unaligned data.
//
- Ptr = (UINT8 *) &Data64;
- Data32 = VmReadCode32 (VmPtr, Offset);
- *(UINT32 *) Ptr = Data32;
- Ptr += sizeof (Data32);
- Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
- *(UINT32 *) Ptr = Data32;
+ Ptr = (UINT8 *)&Data64;
+ Data32 = VmReadCode32 (VmPtr, Offset);
+ *(UINT32 *)Ptr = Data32;
+ Ptr += sizeof (Data32);
+ Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32));
+ *(UINT32 *)Ptr = Data32;
return Data64;
}
-
/**
Reads 8-bit data form the memory address.
@@ -5174,8 +5211,8 @@ VmReadCode64 ( **/
UINT8
VmReadMem8 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
//
@@ -5185,7 +5222,7 @@ VmReadMem8 ( //
// Simply return the data in flat memory space
//
- return * (UINT8 *) Addr;
+ return *(UINT8 *)Addr;
}
/**
@@ -5199,8 +5236,8 @@ VmReadMem8 ( **/
UINT16
VmReadMem16 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
//
@@ -5211,12 +5248,13 @@ VmReadMem16 ( // Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT16))) {
- return * (UINT16 *) Addr;
+ return *(UINT16 *)Addr;
}
+
//
// Return unaligned data
//
- return (UINT16) (*(UINT8 *) Addr + (*(UINT8 *) (Addr + 1) << 8));
+ return (UINT16)(*(UINT8 *)Addr + (*(UINT8 *)(Addr + 1) << 8));
}
/**
@@ -5230,8 +5268,8 @@ VmReadMem16 ( **/
UINT32
VmReadMem32 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
UINT32 Data;
@@ -5244,12 +5282,13 @@ VmReadMem32 ( // Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT32))) {
- return * (UINT32 *) Addr;
+ return *(UINT32 *)Addr;
}
+
//
// Return unaligned data
//
- Data = (UINT32) VmReadMem16 (VmPtr, Addr);
+ Data = (UINT32)VmReadMem16 (VmPtr, Addr);
Data |= (VmReadMem16 (VmPtr, Addr + 2) << 16);
return Data;
}
@@ -5265,8 +5304,8 @@ VmReadMem32 ( **/
UINT64
VmReadMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
UINT64 Data;
@@ -5281,18 +5320,18 @@ VmReadMem64 ( // Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT64))) {
- return * (UINT64 *) Addr;
+ return *(UINT64 *)Addr;
}
+
//
// Return unaligned data. Assume little endian.
//
Data32 = VmReadMem32 (VmPtr, Addr);
- Data = (UINT64) VmReadMem32 (VmPtr, Addr + sizeof (UINT32));
- Data = LShiftU64 (Data, 32) | Data32;
+ Data = (UINT64)VmReadMem32 (VmPtr, Addr + sizeof (UINT32));
+ Data = LShiftU64 (Data, 32) | Data32;
return Data;
}
-
/**
Given an address that EBC is going to read from or write to, return
an appropriate address that accounts for a gap in the stack.
@@ -5314,15 +5353,14 @@ VmReadMem64 ( **/
UINTN
ConvertStackAddr (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
- ASSERT(((Addr < VmPtr->LowStackTop) || (Addr > VmPtr->HighStackBottom)));
+ ASSERT (((Addr < VmPtr->LowStackTop) || (Addr > VmPtr->HighStackBottom)));
return Addr;
}
-
/**
Read a natural value from memory. May or may not be aligned.
@@ -5334,14 +5372,15 @@ ConvertStackAddr ( **/
UINTN
VmReadMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr
)
{
- UINTN Data;
+ UINTN Data;
volatile UINT32 Size;
- UINT8 *FromPtr;
- UINT8 *ToPtr;
+ UINT8 *FromPtr;
+ UINT8 *ToPtr;
+
//
// Convert the address if it's in the stack gap
//
@@ -5350,14 +5389,15 @@ VmReadMemN ( // Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINTN))) {
- return * (UINTN *) Addr;
+ return *(UINTN *)Addr;
}
+
//
// Return unaligned data
//
Data = 0;
- FromPtr = (UINT8 *) Addr;
- ToPtr = (UINT8 *) &Data;
+ FromPtr = (UINT8 *)Addr;
+ ToPtr = (UINT8 *)&Data;
for (Size = 0; Size < sizeof (Data); Size++) {
*ToPtr = *FromPtr;
@@ -5379,5 +5419,5 @@ GetVmVersion ( VOID
)
{
- return (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)));
+ return (UINT64)(((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)));
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h index 1cb68bc538..32b8670c5b 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h @@ -20,8 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Debug macro
//
-#define EBCMSG(s) gST->ConOut->OutputString (gST->ConOut, s)
-
+#define EBCMSG(s) gST->ConOut->OutputString (gST->ConOut, s)
/**
Execute an EBC image from an entry point or from a published protocol.
@@ -34,11 +33,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
EFI_STATUS
EbcExecute (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
-
-
/**
Returns the version of the EBC virtual machine.
@@ -75,9 +72,9 @@ GetVmVersion ( **/
EFI_STATUS
VmWriteMemN (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINTN Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINTN Data
);
/**
@@ -105,9 +102,9 @@ VmWriteMemN ( **/
EFI_STATUS
VmWriteMem64 (
- IN VM_CONTEXT *VmPtr,
- IN UINTN Addr,
- IN UINT64 Data
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN Addr,
+ IN UINT64 Data
);
/**
@@ -127,9 +124,9 @@ VmWriteMem64 ( EFI_STATUS
EFIAPI
EbcExecuteInstructions (
- IN EFI_EBC_VM_TEST_PROTOCOL *This,
- IN VM_CONTEXT *VmPtr,
- IN OUT UINTN *InstructionCount
+ IN EFI_EBC_VM_TEST_PROTOCOL *This,
+ IN VM_CONTEXT *VmPtr,
+ IN OUT UINTN *InstructionCount
);
#endif // ifndef _EBC_EXECUTE_H_
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.c b/MdeModulePkg/Universal/EbcDxe/EbcInt.c index a255b4acc3..d2254c2765 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.c @@ -20,15 +20,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
typedef struct _EBC_THUNK_LIST EBC_THUNK_LIST;
struct _EBC_THUNK_LIST {
- VOID *ThunkBuffer;
- EBC_THUNK_LIST *Next;
+ VOID *ThunkBuffer;
+ EBC_THUNK_LIST *Next;
};
typedef struct _EBC_IMAGE_LIST EBC_IMAGE_LIST;
struct _EBC_IMAGE_LIST {
- EBC_IMAGE_LIST *Next;
- EFI_HANDLE ImageHandle;
- EBC_THUNK_LIST *ThunkList;
+ EBC_IMAGE_LIST *Next;
+ EFI_HANDLE ImageHandle;
+ EBC_THUNK_LIST *ThunkList;
};
/**
@@ -48,8 +48,8 @@ struct _EBC_IMAGE_LIST { EFI_STATUS
EFIAPI
EbcUnloadImage (
- IN EFI_EBC_PROTOCOL *This,
- IN EFI_HANDLE ImageHandle
+ IN EFI_EBC_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle
);
/**
@@ -74,10 +74,10 @@ EbcUnloadImage ( EFI_STATUS
EFIAPI
EbcCreateThunk (
- IN EFI_EBC_PROTOCOL *This,
- IN EFI_HANDLE ImageHandle,
- IN VOID *EbcEntryPoint,
- OUT VOID **Thunk
+ IN EFI_EBC_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk
);
/**
@@ -94,8 +94,8 @@ EbcCreateThunk ( EFI_STATUS
EFIAPI
EbcGetVersion (
- IN EFI_EBC_PROTOCOL *This,
- IN OUT UINT64 *Version
+ IN EFI_EBC_PROTOCOL *This,
+ IN OUT UINT64 *Version
);
/**
@@ -126,8 +126,8 @@ InitializeEbcCallback ( VOID
EFIAPI
CommonEbcExceptionHandler (
- IN EFI_EXCEPTION_TYPE InterruptType,
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_SYSTEM_CONTEXT SystemContext
);
/**
@@ -141,8 +141,8 @@ CommonEbcExceptionHandler ( VOID
EFIAPI
EbcPeriodicNotifyFunction (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -158,13 +158,14 @@ EbcPeriodicNotifyFunction ( EFI_STATUS
EFIAPI
EbcDebugPeriodic (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
);
//
// These two functions and the GUID are used to produce an EBC test protocol.
// This functionality is definitely not required for execution.
//
+
/**
Produces an EBC VM test protocol that can be used for regression tests.
@@ -176,7 +177,7 @@ EbcDebugPeriodic ( **/
EFI_STATUS
InitEbcVmTestProtocol (
- IN EFI_HANDLE *IHandle
+ IN EFI_HANDLE *IHandle
);
/**
@@ -204,8 +205,8 @@ EbcVmTestUnsupported ( EFI_STATUS
EFIAPI
EbcRegisterICacheFlush (
- IN EFI_EBC_PROTOCOL *This,
- IN EBC_ICACHE_FLUSH Flush
+ IN EFI_EBC_PROTOCOL *This,
+ IN EBC_ICACHE_FLUSH Flush
);
/**
@@ -222,8 +223,8 @@ EbcRegisterICacheFlush ( EFI_STATUS
EFIAPI
EbcDebugGetMaximumProcessorIndex (
- IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
- OUT UINTN *MaxProcessorIndex
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
+ OUT UINTN *MaxProcessorIndex
);
/**
@@ -308,10 +309,10 @@ EbcDebugRegisterExceptionCallback ( EFI_STATUS
EFIAPI
EbcDebugInvalidateInstructionCache (
- IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
- IN UINTN ProcessorIndex,
- IN VOID *Start,
- IN UINT64 Length
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
+ IN UINTN ProcessorIndex,
+ IN VOID *Start,
+ IN UINT64 Length
);
//
@@ -320,28 +321,28 @@ EbcDebugInvalidateInstructionCache ( // also be global since the execution of an EBC image does not provide
// a This pointer.
//
-EBC_IMAGE_LIST *mEbcImageList = NULL;
+EBC_IMAGE_LIST *mEbcImageList = NULL;
//
// Callback function to flush the icache after thunk creation
//
-EBC_ICACHE_FLUSH mEbcICacheFlush;
+EBC_ICACHE_FLUSH mEbcICacheFlush;
//
// These get set via calls by the debug agent
//
-EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL;
-EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};
+EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL;
+EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = { NULL };
-VOID *mStackBuffer[MAX_STACK_NUM];
-EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];
-UINTN mStackNum = 0;
+VOID *mStackBuffer[MAX_STACK_NUM];
+EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];
+UINTN mStackNum = 0;
//
// Event for Periodic callback
//
-EFI_EVENT mEbcPeriodicEvent;
-VM_CONTEXT *mVmPtr = NULL;
+EFI_EVENT mEbcPeriodicEvent;
+VM_CONTEXT *mVmPtr = NULL;
/**
Check whether the emulator supports executing a certain PE/COFF image
@@ -359,15 +360,17 @@ VM_CONTEXT *mVmPtr = NULL; BOOLEAN
EFIAPI
EbcIsImageSupported (
- IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
- IN UINT16 ImageType,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL
+ IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
+ IN UINT16 ImageType,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL
)
{
- if (ImageType != EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION &&
- ImageType != EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) {
+ if ((ImageType != EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) &&
+ (ImageType != EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER))
+ {
return FALSE;
}
+
return TRUE;
}
@@ -396,36 +399,44 @@ EbcIsImageSupported ( EFI_STATUS
EFIAPI
EbcRegisterImage (
- IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
- IN EFI_PHYSICAL_ADDRESS ImageBase,
- IN UINT64 ImageSize,
- IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint
+ IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS ImageBase,
+ IN UINT64 ImageSize,
+ IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint
)
{
DEBUG_CODE_BEGIN ();
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
- EFI_STATUS Status;
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+ EFI_STATUS Status;
- ZeroMem (&ImageContext, sizeof (ImageContext));
+ ZeroMem (&ImageContext, sizeof (ImageContext));
- ImageContext.Handle = (VOID *)(UINTN)ImageBase;
- ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
+ ImageContext.Handle = (VOID *)(UINTN)ImageBase;
+ ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
- Status = PeCoffLoaderGetImageInfo (&ImageContext);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ Status = PeCoffLoaderGetImageInfo (&ImageContext);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
- ASSERT (ImageContext.Machine == EFI_IMAGE_MACHINE_EBC);
- ASSERT (ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION ||
- ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER);
+ ASSERT (ImageContext.Machine == EFI_IMAGE_MACHINE_EBC);
+ ASSERT (
+ ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION ||
+ ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
+ );
DEBUG_CODE_END ();
- EbcRegisterICacheFlush (NULL,
- (EBC_ICACHE_FLUSH)InvalidateInstructionCacheRange);
-
- return EbcCreateThunk (NULL, (VOID *)(UINTN)ImageBase,
- (VOID *)(UINTN)*EntryPoint, (VOID **)EntryPoint);
+ EbcRegisterICacheFlush (
+ NULL,
+ (EBC_ICACHE_FLUSH)InvalidateInstructionCacheRange
+ );
+
+ return EbcCreateThunk (
+ NULL,
+ (VOID *)(UINTN)ImageBase,
+ (VOID *)(UINTN)*EntryPoint,
+ (VOID **)EntryPoint
+ );
}
/**
@@ -442,14 +453,14 @@ EbcRegisterImage ( EFI_STATUS
EFIAPI
EbcUnregisterImage (
- IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
- IN EFI_PHYSICAL_ADDRESS ImageBase
+ IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS ImageBase
)
{
return EbcUnloadImage (NULL, (VOID *)(UINTN)ImageBase);
}
-STATIC EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL mPeCoffEmuProtocol = {
+STATIC EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL mPeCoffEmuProtocol = {
EbcIsImageSupported,
EbcRegisterImage,
EbcUnregisterImage,
@@ -470,8 +481,8 @@ STATIC EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL mPeCoffEmuProtocol = { EFI_STATUS
EFIAPI
InitializeEbcDriver (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_EBC_PROTOCOL *EbcProtocol;
@@ -495,24 +506,24 @@ InitializeEbcDriver ( return EFI_OUT_OF_RESOURCES;
}
- EbcProtocol->CreateThunk = EbcCreateThunk;
- EbcProtocol->UnloadImage = EbcUnloadImage;
- EbcProtocol->RegisterICacheFlush = EbcRegisterICacheFlush;
- EbcProtocol->GetVersion = EbcGetVersion;
- mEbcICacheFlush = NULL;
+ EbcProtocol->CreateThunk = EbcCreateThunk;
+ EbcProtocol->UnloadImage = EbcUnloadImage;
+ EbcProtocol->RegisterICacheFlush = EbcRegisterICacheFlush;
+ EbcProtocol->GetVersion = EbcGetVersion;
+ mEbcICacheFlush = NULL;
//
// Find any already-installed EBC protocols and uninstall them
//
- Installed = FALSE;
- HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiEbcProtocolGuid,
- NULL,
- &NumHandles,
- &HandleBuffer
- );
+ Installed = FALSE;
+ HandleBuffer = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiEbcProtocolGuid,
+ NULL,
+ &NumHandles,
+ &HandleBuffer
+ );
if (Status == EFI_SUCCESS) {
//
// Loop through the handles
@@ -521,15 +532,16 @@ InitializeEbcDriver ( Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiEbcProtocolGuid,
- (VOID **) &OldEbcProtocol
+ (VOID **)&OldEbcProtocol
);
if (Status == EFI_SUCCESS) {
if (gBS->ReinstallProtocolInterface (
- HandleBuffer[Index],
- &gEfiEbcProtocolGuid,
- OldEbcProtocol,
- EbcProtocol
- ) == EFI_SUCCESS) {
+ HandleBuffer[Index],
+ &gEfiEbcProtocolGuid,
+ OldEbcProtocol,
+ EbcProtocol
+ ) == EFI_SUCCESS)
+ {
Installed = TRUE;
}
}
@@ -540,14 +552,17 @@ InitializeEbcDriver ( FreePool (HandleBuffer);
HandleBuffer = NULL;
}
+
//
// Add the protocol so someone can locate us if we haven't already.
//
if (!Installed) {
Status = gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
- &gEfiEbcProtocolGuid, EbcProtocol,
- &gEdkiiPeCoffImageEmulatorProtocolGuid, &mPeCoffEmuProtocol,
+ &gEfiEbcProtocolGuid,
+ EbcProtocol,
+ &gEdkiiPeCoffImageEmulatorProtocolGuid,
+ &mPeCoffEmuProtocol,
NULL
);
if (EFI_ERROR (Status)) {
@@ -556,8 +571,8 @@ InitializeEbcDriver ( }
}
- Status = InitEBCStack();
- if (EFI_ERROR(Status)) {
+ Status = InitEBCStack ();
+ if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -570,11 +585,11 @@ InitializeEbcDriver ( goto ErrorExit;
}
- EbcDebugProtocol->Isa = IsaEbc;
- EbcDebugProtocol->GetMaximumProcessorIndex = EbcDebugGetMaximumProcessorIndex;
- EbcDebugProtocol->RegisterPeriodicCallback = EbcDebugRegisterPeriodicCallback;
- EbcDebugProtocol->RegisterExceptionCallback = EbcDebugRegisterExceptionCallback;
- EbcDebugProtocol->InvalidateInstructionCache = EbcDebugInvalidateInstructionCache;
+ EbcDebugProtocol->Isa = IsaEbc;
+ EbcDebugProtocol->GetMaximumProcessorIndex = EbcDebugGetMaximumProcessorIndex;
+ EbcDebugProtocol->RegisterPeriodicCallback = EbcDebugRegisterPeriodicCallback;
+ EbcDebugProtocol->RegisterExceptionCallback = EbcDebugRegisterExceptionCallback;
+ EbcDebugProtocol->InvalidateInstructionCache = EbcDebugInvalidateInstructionCache;
//
// Add the protocol so the debug agent can find us
@@ -592,6 +607,7 @@ InitializeEbcDriver ( FreePool (EbcDebugProtocol);
goto ErrorExit;
}
+
//
// Install EbcDebugSupport Protocol Successfully
// Now we need to initialize the Ebc default Callback
@@ -602,7 +618,7 @@ InitializeEbcDriver ( // Produce a VM test interface protocol. Not required for execution.
//
DEBUG_CODE_BEGIN ();
- InitEbcVmTestProtocol (&ImageHandle);
+ InitEbcVmTestProtocol (&ImageHandle);
DEBUG_CODE_END ();
EbcDebuggerHookInit (ImageHandle, EbcDebugProtocol);
@@ -610,15 +626,15 @@ InitializeEbcDriver ( return EFI_SUCCESS;
ErrorExit:
- FreeEBCStack();
- HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiEbcProtocolGuid,
- NULL,
- &NumHandles,
- &HandleBuffer
- );
+ FreeEBCStack ();
+ HandleBuffer = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiEbcProtocolGuid,
+ NULL,
+ &NumHandles,
+ &HandleBuffer
+ );
if (Status == EFI_SUCCESS) {
//
// Loop through the handles
@@ -627,7 +643,7 @@ ErrorExit: Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiEbcProtocolGuid,
- (VOID **) &OldEbcProtocol
+ (VOID **)&OldEbcProtocol
);
if (Status == EFI_SUCCESS) {
gBS->UninstallProtocolInterface (
@@ -649,7 +665,6 @@ ErrorExit: return Status;
}
-
/**
This is the top-level routine plugged into the EBC protocol. Since thunks
are very processor-specific, from here we dispatch directly to the very
@@ -672,24 +687,23 @@ ErrorExit: EFI_STATUS
EFIAPI
EbcCreateThunk (
- IN EFI_EBC_PROTOCOL *This,
- IN EFI_HANDLE ImageHandle,
- IN VOID *EbcEntryPoint,
- OUT VOID **Thunk
+ IN EFI_EBC_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk
)
{
EFI_STATUS Status;
Status = EbcCreateThunks (
- ImageHandle,
- EbcEntryPoint,
- Thunk,
- FLAG_THUNK_ENTRY_POINT
- );
+ ImageHandle,
+ EbcEntryPoint,
+ Thunk,
+ FLAG_THUNK_ENTRY_POINT
+ );
return Status;
}
-
/**
This EBC debugger protocol service is called by the debug agent
@@ -704,15 +718,14 @@ EbcCreateThunk ( EFI_STATUS
EFIAPI
EbcDebugGetMaximumProcessorIndex (
- IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
- OUT UINTN *MaxProcessorIndex
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
+ OUT UINTN *MaxProcessorIndex
)
{
*MaxProcessorIndex = 0;
return EFI_SUCCESS;
}
-
/**
This protocol service is called by the debug agent to register a function
for us to call on a periodic basis.
@@ -745,6 +758,7 @@ EbcDebugRegisterPeriodicCallback ( if ((mDebugPeriodicCallback == NULL) && (PeriodicCallback == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
if ((mDebugPeriodicCallback != NULL) && (PeriodicCallback != NULL)) {
return EFI_ALREADY_STARTED;
}
@@ -753,7 +767,6 @@ EbcDebugRegisterPeriodicCallback ( return EFI_SUCCESS;
}
-
/**
This protocol service is called by the debug agent to register a function
for us to call when we detect an exception.
@@ -791,17 +804,19 @@ EbcDebugRegisterExceptionCallback ( if ((ExceptionType < 0) || (ExceptionType > MAX_EBC_EXCEPTION)) {
return EFI_INVALID_PARAMETER;
}
+
if ((mDebugExceptionCallback[ExceptionType] == NULL) && (ExceptionCallback == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
if ((mDebugExceptionCallback[ExceptionType] != NULL) && (ExceptionCallback != NULL)) {
return EFI_ALREADY_STARTED;
}
+
mDebugExceptionCallback[ExceptionType] = ExceptionCallback;
return EFI_SUCCESS;
}
-
/**
This EBC debugger protocol service is called by the debug agent. Required
for DebugSupport compliance but is only stubbed out for EBC.
@@ -821,16 +836,15 @@ EbcDebugRegisterExceptionCallback ( EFI_STATUS
EFIAPI
EbcDebugInvalidateInstructionCache (
- IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
- IN UINTN ProcessorIndex,
- IN VOID *Start,
- IN UINT64 Length
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
+ IN UINTN ProcessorIndex,
+ IN VOID *Start,
+ IN UINT64 Length
)
{
return EFI_SUCCESS;
}
-
/**
The VM interpreter calls this function when an exception is detected.
@@ -844,9 +858,9 @@ EbcDebugInvalidateInstructionCache ( **/
EFI_STATUS
EbcDebugSignalException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EXCEPTION_FLAGS ExceptionFlags,
- IN VM_CONTEXT *VmPtr
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN EXCEPTION_FLAGS ExceptionFlags,
+ IN VM_CONTEXT *VmPtr
)
{
EFI_SYSTEM_CONTEXT_EBC EbcContext;
@@ -857,7 +871,7 @@ EbcDebugSignalException ( // Save the exception in the context passed in
//
VmPtr->ExceptionFlags |= ExceptionFlags;
- VmPtr->LastException = (UINTN) ExceptionType;
+ VmPtr->LastException = (UINTN)ExceptionType;
//
// If it's a fatal exception, then flag it in the VM context in case an
// attached debugger tries to return from it.
@@ -873,43 +887,41 @@ EbcDebugSignalException ( // status code via the status code API
//
if (mDebugExceptionCallback[ExceptionType] != NULL) {
-
//
// Initialize the context structure
//
- EbcContext.R0 = (UINT64) VmPtr->Gpr[0];
- EbcContext.R1 = (UINT64) VmPtr->Gpr[1];
- EbcContext.R2 = (UINT64) VmPtr->Gpr[2];
- EbcContext.R3 = (UINT64) VmPtr->Gpr[3];
- EbcContext.R4 = (UINT64) VmPtr->Gpr[4];
- EbcContext.R5 = (UINT64) VmPtr->Gpr[5];
- EbcContext.R6 = (UINT64) VmPtr->Gpr[6];
- EbcContext.R7 = (UINT64) VmPtr->Gpr[7];
- EbcContext.Ip = (UINT64)(UINTN)VmPtr->Ip;
- EbcContext.Flags = VmPtr->Flags;
- EbcContext.ControlFlags = 0;
- SystemContext.SystemContextEbc = &EbcContext;
-
- mDebugExceptionCallback[ExceptionType] (ExceptionType, SystemContext);
+ EbcContext.R0 = (UINT64)VmPtr->Gpr[0];
+ EbcContext.R1 = (UINT64)VmPtr->Gpr[1];
+ EbcContext.R2 = (UINT64)VmPtr->Gpr[2];
+ EbcContext.R3 = (UINT64)VmPtr->Gpr[3];
+ EbcContext.R4 = (UINT64)VmPtr->Gpr[4];
+ EbcContext.R5 = (UINT64)VmPtr->Gpr[5];
+ EbcContext.R6 = (UINT64)VmPtr->Gpr[6];
+ EbcContext.R7 = (UINT64)VmPtr->Gpr[7];
+ EbcContext.Ip = (UINT64)(UINTN)VmPtr->Ip;
+ EbcContext.Flags = VmPtr->Flags;
+ EbcContext.ControlFlags = 0;
+ SystemContext.SystemContextEbc = &EbcContext;
+
+ mDebugExceptionCallback[ExceptionType](ExceptionType, SystemContext);
//
// Restore the context structure and continue to execute
//
- VmPtr->Gpr[0] = EbcContext.R0;
- VmPtr->Gpr[1] = EbcContext.R1;
- VmPtr->Gpr[2] = EbcContext.R2;
- VmPtr->Gpr[3] = EbcContext.R3;
- VmPtr->Gpr[4] = EbcContext.R4;
- VmPtr->Gpr[5] = EbcContext.R5;
- VmPtr->Gpr[6] = EbcContext.R6;
- VmPtr->Gpr[7] = EbcContext.R7;
- VmPtr->Ip = (VMIP)(UINTN)EbcContext.Ip;
- VmPtr->Flags = EbcContext.Flags;
+ VmPtr->Gpr[0] = EbcContext.R0;
+ VmPtr->Gpr[1] = EbcContext.R1;
+ VmPtr->Gpr[2] = EbcContext.R2;
+ VmPtr->Gpr[3] = EbcContext.R3;
+ VmPtr->Gpr[4] = EbcContext.R4;
+ VmPtr->Gpr[5] = EbcContext.R5;
+ VmPtr->Gpr[6] = EbcContext.R6;
+ VmPtr->Gpr[7] = EbcContext.R7;
+ VmPtr->Ip = (VMIP)(UINTN)EbcContext.Ip;
+ VmPtr->Flags = EbcContext.Flags;
}
return EFI_SUCCESS;
}
-
/**
To install default Callback function for the VM interpreter.
@@ -926,8 +938,8 @@ InitializeEbcCallback ( IN EFI_DEBUG_SUPPORT_PROTOCOL *This
)
{
- INTN Index;
- EFI_STATUS Status;
+ INTN Index;
+ EFI_STATUS Status;
//
// For ExceptionCallback
@@ -951,7 +963,7 @@ InitializeEbcCallback ( &mVmPtr,
&mEbcPeriodicEvent
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -960,14 +972,13 @@ InitializeEbcCallback ( TimerPeriodic,
EBC_VM_PERIODIC_CALLBACK_RATE
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
return EFI_SUCCESS;
}
-
/**
The default Exception Callback for the VM interpreter.
In this function, we report status code, and print debug information
@@ -980,8 +991,8 @@ InitializeEbcCallback ( VOID
EFIAPI
CommonEbcExceptionHandler (
- IN EFI_EXCEPTION_TYPE InterruptType,
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
//
@@ -990,7 +1001,7 @@ CommonEbcExceptionHandler ( DEBUG ((
DEBUG_ERROR,
"EBC Interrupter Version - 0x%016lx\n",
- (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)))
+ (UINT64)(((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)))
));
DEBUG ((
DEBUG_ERROR,
@@ -1042,10 +1053,9 @@ CommonEbcExceptionHandler ( //
CpuDeadLoop ();
- return ;
+ return;
}
-
/**
The periodic callback function for EBC VM interpreter, which is used
to support the EFI debug support protocol.
@@ -1057,11 +1067,11 @@ CommonEbcExceptionHandler ( VOID
EFIAPI
EbcPeriodicNotifyFunction (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- VM_CONTEXT *VmPtr;
+ VM_CONTEXT *VmPtr;
VmPtr = *(VM_CONTEXT **)Context;
@@ -1069,10 +1079,9 @@ EbcPeriodicNotifyFunction ( EbcDebugPeriodic (VmPtr);
}
- return ;
+ return;
}
-
/**
The VM interpreter calls this function on a periodic basis to support
the EFI debug support protocol.
@@ -1086,54 +1095,52 @@ EbcPeriodicNotifyFunction ( EFI_STATUS
EFIAPI
EbcDebugPeriodic (
- IN VM_CONTEXT *VmPtr
+ IN VM_CONTEXT *VmPtr
)
{
- EFI_SYSTEM_CONTEXT_EBC EbcContext;
- EFI_SYSTEM_CONTEXT SystemContext;
+ EFI_SYSTEM_CONTEXT_EBC EbcContext;
+ EFI_SYSTEM_CONTEXT SystemContext;
//
// If someone's registered for periodic callbacks, then call them.
//
if (mDebugPeriodicCallback != NULL) {
-
//
// Initialize the context structure
//
- EbcContext.R0 = (UINT64) VmPtr->Gpr[0];
- EbcContext.R1 = (UINT64) VmPtr->Gpr[1];
- EbcContext.R2 = (UINT64) VmPtr->Gpr[2];
- EbcContext.R3 = (UINT64) VmPtr->Gpr[3];
- EbcContext.R4 = (UINT64) VmPtr->Gpr[4];
- EbcContext.R5 = (UINT64) VmPtr->Gpr[5];
- EbcContext.R6 = (UINT64) VmPtr->Gpr[6];
- EbcContext.R7 = (UINT64) VmPtr->Gpr[7];
- EbcContext.Ip = (UINT64)(UINTN)VmPtr->Ip;
- EbcContext.Flags = VmPtr->Flags;
- EbcContext.ControlFlags = 0;
- SystemContext.SystemContextEbc = &EbcContext;
+ EbcContext.R0 = (UINT64)VmPtr->Gpr[0];
+ EbcContext.R1 = (UINT64)VmPtr->Gpr[1];
+ EbcContext.R2 = (UINT64)VmPtr->Gpr[2];
+ EbcContext.R3 = (UINT64)VmPtr->Gpr[3];
+ EbcContext.R4 = (UINT64)VmPtr->Gpr[4];
+ EbcContext.R5 = (UINT64)VmPtr->Gpr[5];
+ EbcContext.R6 = (UINT64)VmPtr->Gpr[6];
+ EbcContext.R7 = (UINT64)VmPtr->Gpr[7];
+ EbcContext.Ip = (UINT64)(UINTN)VmPtr->Ip;
+ EbcContext.Flags = VmPtr->Flags;
+ EbcContext.ControlFlags = 0;
+ SystemContext.SystemContextEbc = &EbcContext;
mDebugPeriodicCallback (SystemContext);
//
// Restore the context structure and continue to execute
//
- VmPtr->Gpr[0] = EbcContext.R0;
- VmPtr->Gpr[1] = EbcContext.R1;
- VmPtr->Gpr[2] = EbcContext.R2;
- VmPtr->Gpr[3] = EbcContext.R3;
- VmPtr->Gpr[4] = EbcContext.R4;
- VmPtr->Gpr[5] = EbcContext.R5;
- VmPtr->Gpr[6] = EbcContext.R6;
- VmPtr->Gpr[7] = EbcContext.R7;
- VmPtr->Ip = (VMIP)(UINTN)EbcContext.Ip;
- VmPtr->Flags = EbcContext.Flags;
+ VmPtr->Gpr[0] = EbcContext.R0;
+ VmPtr->Gpr[1] = EbcContext.R1;
+ VmPtr->Gpr[2] = EbcContext.R2;
+ VmPtr->Gpr[3] = EbcContext.R3;
+ VmPtr->Gpr[4] = EbcContext.R4;
+ VmPtr->Gpr[5] = EbcContext.R5;
+ VmPtr->Gpr[6] = EbcContext.R6;
+ VmPtr->Gpr[7] = EbcContext.R7;
+ VmPtr->Ip = (VMIP)(UINTN)EbcContext.Ip;
+ VmPtr->Flags = EbcContext.Flags;
}
return EFI_SUCCESS;
}
-
/**
This routine is called by the core when an image is being unloaded from
memory. Basically we now have the opportunity to do any necessary cleanup.
@@ -1151,24 +1158,26 @@ EbcDebugPeriodic ( EFI_STATUS
EFIAPI
EbcUnloadImage (
- IN EFI_EBC_PROTOCOL *This,
- IN EFI_HANDLE ImageHandle
+ IN EFI_EBC_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle
)
{
EBC_THUNK_LIST *ThunkList;
EBC_THUNK_LIST *NextThunkList;
EBC_IMAGE_LIST *ImageList;
EBC_IMAGE_LIST *PrevImageList;
+
//
// First go through our list of known image handles and see if we've already
// created an image list element for this image handle.
//
- ReturnEBCStackByHandle(ImageHandle);
+ ReturnEBCStackByHandle (ImageHandle);
PrevImageList = NULL;
for (ImageList = mEbcImageList; ImageList != NULL; ImageList = ImageList->Next) {
if (ImageList->ImageHandle == ImageHandle) {
break;
}
+
//
// Save the previous so we can connect the lists when we remove this one
//
@@ -1178,6 +1187,7 @@ EbcUnloadImage ( if (ImageList == NULL) {
return EFI_INVALID_PARAMETER;
}
+
//
// Free up all the thunk buffers and thunks list elements for this image
// handle.
@@ -1189,6 +1199,7 @@ EbcUnloadImage ( FreePool (ThunkList);
ThunkList = NextThunkList;
}
+
//
// Now remove this image list element from the chain
//
@@ -1200,6 +1211,7 @@ EbcUnloadImage ( } else {
PrevImageList->Next = ImageList->Next;
}
+
//
// Now free up the image list element
//
@@ -1210,7 +1222,6 @@ EbcUnloadImage ( return EFI_SUCCESS;
}
-
/**
Add a thunk to our list of thunks for a given image handle.
Also flush the instruction cache since we've written thunk code
@@ -1226,9 +1237,9 @@ EbcUnloadImage ( **/
EFI_STATUS
EbcAddImageThunk (
- IN EFI_HANDLE ImageHandle,
- IN VOID *ThunkBuffer,
- IN UINT32 ThunkSize
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *ThunkBuffer,
+ IN UINT32 ThunkSize
)
{
EBC_THUNK_LIST *ThunkList;
@@ -1239,11 +1250,12 @@ EbcAddImageThunk ( // It so far so good, then flush the instruction cache
//
if (mEbcICacheFlush != NULL) {
- Status = mEbcICacheFlush ((EFI_PHYSICAL_ADDRESS) (UINTN) ThunkBuffer, ThunkSize);
+ Status = mEbcICacheFlush ((EFI_PHYSICAL_ADDRESS)(UINTN)ThunkBuffer, ThunkSize);
if (EFI_ERROR (Status)) {
return Status;
}
}
+
//
// Go through our list of known image handles and see if we've already
// created a image list element for this image handle.
@@ -1264,11 +1276,12 @@ EbcAddImageThunk ( return EFI_OUT_OF_RESOURCES;
}
- ImageList->ThunkList = NULL;
- ImageList->ImageHandle = ImageHandle;
- ImageList->Next = mEbcImageList;
- mEbcImageList = ImageList;
+ ImageList->ThunkList = NULL;
+ ImageList->ImageHandle = ImageHandle;
+ ImageList->Next = mEbcImageList;
+ mEbcImageList = ImageList;
}
+
//
// Ok, now create a new thunk element to add to the list
//
@@ -1277,12 +1290,13 @@ EbcAddImageThunk ( if (ThunkList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Add it to the head of the list
//
- ThunkList->Next = ImageList->ThunkList;
- ThunkList->ThunkBuffer = ThunkBuffer;
- ImageList->ThunkList = ThunkList;
+ ThunkList->Next = ImageList->ThunkList;
+ ThunkList->ThunkBuffer = ThunkBuffer;
+ ImageList->ThunkList = ThunkList;
return EFI_SUCCESS;
}
@@ -1299,8 +1313,8 @@ EbcAddImageThunk ( EFI_STATUS
EFIAPI
EbcRegisterICacheFlush (
- IN EFI_EBC_PROTOCOL *This,
- IN EBC_ICACHE_FLUSH Flush
+ IN EFI_EBC_PROTOCOL *This,
+ IN EBC_ICACHE_FLUSH Flush
)
{
mEbcICacheFlush = Flush;
@@ -1321,8 +1335,8 @@ EbcRegisterICacheFlush ( EFI_STATUS
EFIAPI
EbcGetVersion (
- IN EFI_EBC_PROTOCOL *This,
- IN OUT UINT64 *Version
+ IN EFI_EBC_PROTOCOL *This,
+ IN OUT UINT64 *Version
)
{
if (Version == NULL) {
@@ -1347,25 +1361,28 @@ EbcGetVersion ( **/
EFI_STATUS
-GetEBCStack(
- IN EFI_HANDLE Handle,
- OUT VOID **StackBuffer,
- OUT UINTN *BufferIndex
+GetEBCStack (
+ IN EFI_HANDLE Handle,
+ OUT VOID **StackBuffer,
+ OUT UINTN *BufferIndex
)
{
- UINTN Index;
- EFI_TPL OldTpl;
- OldTpl = gBS->RaiseTPL(TPL_HIGH_LEVEL);
- for (Index = 0; Index < mStackNum; Index ++) {
+ UINTN Index;
+ EFI_TPL OldTpl;
+
+ OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+ for (Index = 0; Index < mStackNum; Index++) {
if (mStackBufferIndex[Index] == NULL) {
mStackBufferIndex[Index] = Handle;
break;
}
}
- gBS->RestoreTPL(OldTpl);
+
+ gBS->RestoreTPL (OldTpl);
if (Index == mStackNum) {
return EFI_OUT_OF_RESOURCES;
}
+
*BufferIndex = Index;
*StackBuffer = mStackBuffer[Index];
return EFI_SUCCESS;
@@ -1380,8 +1397,8 @@ GetEBCStack( **/
EFI_STATUS
-ReturnEBCStack(
- IN UINTN Index
+ReturnEBCStack (
+ IN UINTN Index
)
{
mStackBufferIndex[Index] = NULL;
@@ -1397,19 +1414,22 @@ ReturnEBCStack( **/
EFI_STATUS
-ReturnEBCStackByHandle(
- IN EFI_HANDLE Handle
+ReturnEBCStackByHandle (
+ IN EFI_HANDLE Handle
)
{
- UINTN Index;
- for (Index = 0; Index < mStackNum; Index ++) {
+ UINTN Index;
+
+ for (Index = 0; Index < mStackNum; Index++) {
if (mStackBufferIndex[Index] == Handle) {
break;
}
}
+
if (Index == mStackNum) {
return EFI_NOT_FOUND;
}
+
mStackBufferIndex[Index] = NULL;
return EFI_SUCCESS;
}
@@ -1426,20 +1446,21 @@ InitEBCStack ( VOID
)
{
- for (mStackNum = 0; mStackNum < MAX_STACK_NUM; mStackNum ++) {
- mStackBuffer[mStackNum] = AllocatePool(STACK_POOL_SIZE);
+ for (mStackNum = 0; mStackNum < MAX_STACK_NUM; mStackNum++) {
+ mStackBuffer[mStackNum] = AllocatePool (STACK_POOL_SIZE);
mStackBufferIndex[mStackNum] = NULL;
if (mStackBuffer[mStackNum] == NULL) {
break;
}
}
+
if (mStackNum == 0) {
return EFI_OUT_OF_RESOURCES;
}
+
return EFI_SUCCESS;
}
-
/**
Free all EBC stacks allocated before.
@@ -1447,14 +1468,16 @@ InitEBCStack ( **/
EFI_STATUS
-FreeEBCStack(
+FreeEBCStack (
VOID
)
{
- UINTN Index;
- for (Index = 0; Index < mStackNum; Index ++) {
- FreePool(mStackBuffer[Index]);
+ UINTN Index;
+
+ for (Index = 0; Index < mStackNum; Index++) {
+ FreePool (mStackBuffer[Index]);
}
+
return EFI_SUCCESS;
}
@@ -1469,12 +1492,12 @@ FreeEBCStack( **/
EFI_STATUS
InitEbcVmTestProtocol (
- IN EFI_HANDLE *IHandle
+ IN EFI_HANDLE *IHandle
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- EFI_EBC_VM_TEST_PROTOCOL *EbcVmTestProtocol;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ EFI_EBC_VM_TEST_PROTOCOL *EbcVmTestProtocol;
//
// Allocate memory for the protocol, then fill in the fields
@@ -1483,25 +1506,26 @@ InitEbcVmTestProtocol ( if (EbcVmTestProtocol == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- EbcVmTestProtocol->Execute = (EBC_VM_TEST_EXECUTE) EbcExecuteInstructions;
+
+ EbcVmTestProtocol->Execute = (EBC_VM_TEST_EXECUTE)EbcExecuteInstructions;
DEBUG_CODE_BEGIN ();
- EbcVmTestProtocol->Assemble = (EBC_VM_TEST_ASM) EbcVmTestUnsupported;
- EbcVmTestProtocol->Disassemble = (EBC_VM_TEST_DASM) EbcVmTestUnsupported;
+ EbcVmTestProtocol->Assemble = (EBC_VM_TEST_ASM)EbcVmTestUnsupported;
+ EbcVmTestProtocol->Disassemble = (EBC_VM_TEST_DASM)EbcVmTestUnsupported;
DEBUG_CODE_END ();
//
// Publish the protocol
//
- Handle = NULL;
- Status = gBS->InstallProtocolInterface (&Handle, &gEfiEbcVmTestProtocolGuid, EFI_NATIVE_INTERFACE, EbcVmTestProtocol);
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (&Handle, &gEfiEbcVmTestProtocolGuid, EFI_NATIVE_INTERFACE, EbcVmTestProtocol);
if (EFI_ERROR (Status)) {
FreePool (EbcVmTestProtocol);
}
+
return Status;
}
-
/**
Returns the EFI_UNSUPPORTED Status.
@@ -1538,5 +1562,6 @@ EbcAllocatePoolForThunk ( if (EFI_ERROR (Status)) {
return NULL;
}
+
return Buffer;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.h b/MdeModulePkg/Universal/EbcDxe/EbcInt.h index 16f5ed4eb1..646e3a613b 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.h @@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _EBC_INT_H_
#define _EBC_INT_H_
-
#include <Uefi.h>
#include <Protocol/DebugSupport.h>
@@ -28,7 +27,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
-extern VM_CONTEXT *mVmPtr;
+extern VM_CONTEXT *mVmPtr;
//
// Flags passed to the internal create-thunks function.
@@ -60,10 +59,10 @@ extern VM_CONTEXT *mVmPtr; **/
EFI_STATUS
EbcCreateThunks (
- IN EFI_HANDLE ImageHandle,
- IN VOID *EbcEntryPoint,
- OUT VOID **Thunk,
- IN UINT32 Flags
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk,
+ IN UINT32 Flags
);
/**
@@ -81,23 +80,24 @@ EbcCreateThunks ( **/
EFI_STATUS
EbcAddImageThunk (
- IN EFI_HANDLE ImageHandle,
- IN VOID *ThunkBuffer,
- IN UINT32 ThunkSize
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *ThunkBuffer,
+ IN UINT32 ThunkSize
);
//
// Define a constant of how often to call the debugger periodic callback
// function.
//
-#define EFI_TIMER_UNIT_1MS (1000 * 10)
-#define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS)
-#define STACK_POOL_SIZE (1024 * 1020)
-#define MAX_STACK_NUM 4
+#define EFI_TIMER_UNIT_1MS (1000 * 10)
+#define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS)
+#define STACK_POOL_SIZE (1024 * 1020)
+#define MAX_STACK_NUM 4
//
// External low level functions that are native-processor dependent
//
+
/**
The VM thunk code stuffs an EBC entry point into a processor
register. Since we can't use inline assembly to get it from
@@ -131,9 +131,9 @@ EbcLLGetEbcEntryPoint ( INT64
EFIAPI
EbcLLCALLEXNative (
- IN UINTN CallAddr,
- IN UINTN EbcSp,
- IN VOID *FramePtr
+ IN UINTN CallAddr,
+ IN UINTN EbcSp,
+ IN VOID *FramePtr
);
/**
@@ -153,11 +153,11 @@ EbcLLCALLEXNative ( **/
VOID
EbcLLCALLEX (
- IN VM_CONTEXT *VmPtr,
- IN UINTN FuncAddr,
- IN UINTN NewStackPointer,
- IN VOID *FramePtr,
- IN UINT8 Size
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN FuncAddr,
+ IN UINTN NewStackPointer,
+ IN VOID *FramePtr,
+ IN UINT8 Size
);
/**
@@ -174,10 +174,10 @@ EbcLLCALLEX ( **/
EFI_STATUS
-GetEBCStack(
- IN EFI_HANDLE Handle,
- OUT VOID **StackBuffer,
- OUT UINTN *BufferIndex
+GetEBCStack (
+ IN EFI_HANDLE Handle,
+ OUT VOID **StackBuffer,
+ OUT UINTN *BufferIndex
);
/**
@@ -189,8 +189,8 @@ GetEBCStack( **/
EFI_STATUS
-ReturnEBCStack(
- IN UINTN Index
+ReturnEBCStack (
+ IN UINTN Index
);
/**
@@ -212,7 +212,7 @@ InitEBCStack ( **/
EFI_STATUS
-FreeEBCStack(
+FreeEBCStack (
VOID
);
@@ -225,24 +225,22 @@ FreeEBCStack( **/
EFI_STATUS
-ReturnEBCStackByHandle(
- IN EFI_HANDLE Handle
+ReturnEBCStackByHandle (
+ IN EFI_HANDLE Handle
);
typedef struct {
- EFI_EBC_PROTOCOL *This;
- VOID *EntryPoint;
- EFI_HANDLE ImageHandle;
- VM_CONTEXT VmContext;
+ EFI_EBC_PROTOCOL *This;
+ VOID *EntryPoint;
+ EFI_HANDLE ImageHandle;
+ VM_CONTEXT VmContext;
} EFI_EBC_THUNK_DATA;
-#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('e', 'b', 'c', 'p')
-
+#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('e', 'b', 'c', 'p')
#define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)
-
/**
Allocates a buffer of type EfiBootServicesCode.
diff --git a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c index a25139536f..d53e94ebf9 100644 --- a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c @@ -17,21 +17,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // based on whether or not a debugger is present, and other
// platform-specific configurations.
//
-#define VM_STACK_SIZE (1024 * 4)
+#define VM_STACK_SIZE (1024 * 4)
-#define STACK_REMAIN_SIZE (1024 * 4)
+#define STACK_REMAIN_SIZE (1024 * 4)
//
// This is instruction buffer used to create EBC thunk
//
-#define EBC_ENTRYPOINT_SIGNATURE 0xAFAFAFAF
-#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE 0xFAFAFAFA
+#define EBC_ENTRYPOINT_SIGNATURE 0xAFAFAFAF
+#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE 0xFAFAFAFA
UINT8 mInstructionBufferTemplate[] = {
//
// Add a magic code here to help the VM recognize the thunk..
// mov eax, 0xca112ebc => B8 BC 2E 11 CA
//
- 0xB8, 0xBC, 0x2E, 0x11, 0xCA,
+ 0xB8, 0xBC, 0x2E, 0x11, 0xCA,
//
// Add code bytes to load up a processor register with the EBC entry point.
// mov eax, EbcEntryPoint => B8 XX XX XX XX (To be fixed at runtime)
@@ -39,24 +39,24 @@ UINT8 mInstructionBufferTemplate[] = { // entry point.
//
0xB8,
- (UINT8)(EBC_ENTRYPOINT_SIGNATURE & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
+ (UINT8)(EBC_ENTRYPOINT_SIGNATURE & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
//
// Stick in a load of ecx with the address of appropriate VM function.
// mov ecx, EbcLLEbcInterpret => B9 XX XX XX XX (To be fixed at runtime)
//
0xB9,
- (UINT8)(EBC_LL_EBC_ENTRYPOINT_SIGNATURE & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
+ (UINT8)(EBC_LL_EBC_ENTRYPOINT_SIGNATURE & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
//
// Stick in jump opcode bytes
// jmp ecx => FF E1
//
- 0xFF, 0xE1,
+ 0xFF, 0xE1,
};
/**
@@ -102,60 +102,62 @@ EbcLLExecuteEbcImageEntryPoint ( **/
VOID
EbcLLCALLEX (
- IN VM_CONTEXT *VmPtr,
- IN UINTN FuncAddr,
- IN UINTN NewStackPointer,
- IN VOID *FramePtr,
- IN UINT8 Size
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN FuncAddr,
+ IN UINTN NewStackPointer,
+ IN VOID *FramePtr,
+ IN UINT8 Size
)
{
- UINTN IsThunk;
- UINTN TargetEbcAddr;
- UINT8 InstructionBuffer[sizeof(mInstructionBufferTemplate)];
- UINTN Index;
- UINTN IndexOfEbcEntrypoint;
-
- IsThunk = 1;
- TargetEbcAddr = 0;
+ UINTN IsThunk;
+ UINTN TargetEbcAddr;
+ UINT8 InstructionBuffer[sizeof (mInstructionBufferTemplate)];
+ UINTN Index;
+ UINTN IndexOfEbcEntrypoint;
+
+ IsThunk = 1;
+ TargetEbcAddr = 0;
IndexOfEbcEntrypoint = 0;
//
// Processor specific code to check whether the callee is a thunk to EBC.
//
- CopyMem (InstructionBuffer, (VOID *)FuncAddr, sizeof(InstructionBuffer));
+ CopyMem (InstructionBuffer, (VOID *)FuncAddr, sizeof (InstructionBuffer));
//
// Fill the signature according to mInstructionBufferTemplate
//
- for (Index = 0; Index < sizeof(mInstructionBufferTemplate) - sizeof(UINTN); Index++) {
+ for (Index = 0; Index < sizeof (mInstructionBufferTemplate) - sizeof (UINTN); Index++) {
if (*(UINTN *)&mInstructionBufferTemplate[Index] == EBC_ENTRYPOINT_SIGNATURE) {
*(UINTN *)&InstructionBuffer[Index] = EBC_ENTRYPOINT_SIGNATURE;
- IndexOfEbcEntrypoint = Index;
+ IndexOfEbcEntrypoint = Index;
}
+
if (*(UINTN *)&mInstructionBufferTemplate[Index] == EBC_LL_EBC_ENTRYPOINT_SIGNATURE) {
*(UINTN *)&InstructionBuffer[Index] = EBC_LL_EBC_ENTRYPOINT_SIGNATURE;
}
}
+
//
// Check if we need thunk to native
//
- if (CompareMem (InstructionBuffer, mInstructionBufferTemplate, sizeof(mInstructionBufferTemplate)) != 0) {
+ if (CompareMem (InstructionBuffer, mInstructionBufferTemplate, sizeof (mInstructionBufferTemplate)) != 0) {
IsThunk = 0;
}
- if (IsThunk == 1){
+ if (IsThunk == 1) {
//
// The callee is a thunk to EBC, adjust the stack pointer down 16 bytes and
// put our return address and frame pointer on the VM stack.
// Then set the VM's IP to new EBC code.
//
VmPtr->Gpr[0] -= 8;
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);
- VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];
- VmPtr->Gpr[0] -= 8;
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], (UINTN)FramePtr);
+ VmPtr->FramePtr = (VOID *)(UINTN)VmPtr->Gpr[0];
+ VmPtr->Gpr[0] -= 8;
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], (UINT64)(UINTN)(VmPtr->Ip + Size));
- CopyMem (&TargetEbcAddr, (UINT8 *)FuncAddr + IndexOfEbcEntrypoint, sizeof(UINTN));
- VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;
+ CopyMem (&TargetEbcAddr, (UINT8 *)FuncAddr + IndexOfEbcEntrypoint, sizeof (UINTN));
+ VmPtr->Ip = (VMIP)(UINTN)TargetEbcAddr;
} else {
//
// The callee is not a thunk to EBC, call native code,
@@ -170,7 +172,6 @@ EbcLLCALLEX ( }
}
-
/**
Begin executing an EBC image.
@@ -202,23 +203,23 @@ EbcLLCALLEX ( UINT64
EFIAPI
EbcInterpret (
- IN UINTN EntryPoint,
- IN UINTN Arg1,
- IN UINTN Arg2,
- IN UINTN Arg3,
- IN UINTN Arg4,
- IN UINTN Arg5,
- IN UINTN Arg6,
- IN UINTN Arg7,
- IN UINTN Arg8,
- IN UINTN Arg9,
- IN UINTN Arg10,
- IN UINTN Arg11,
- IN UINTN Arg12,
- IN UINTN Arg13,
- IN UINTN Arg14,
- IN UINTN Arg15,
- IN UINTN Arg16
+ IN UINTN EntryPoint,
+ IN UINTN Arg1,
+ IN UINTN Arg2,
+ IN UINTN Arg3,
+ IN UINTN Arg4,
+ IN UINTN Arg5,
+ IN UINTN Arg6,
+ IN UINTN Arg7,
+ IN UINTN Arg8,
+ IN UINTN Arg9,
+ IN UINTN Arg10,
+ IN UINTN Arg11,
+ IN UINTN Arg12,
+ IN UINTN Arg13,
+ IN UINTN Arg14,
+ IN UINTN Arg15,
+ IN UINTN Arg16
)
{
//
@@ -237,12 +238,12 @@ EbcInterpret ( //
// Now clear out our context
//
- ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));
+ ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));
//
// Set the VM instruction pointer to the correct location in memory.
//
- VmContext.Ip = (VMIP) Addr;
+ VmContext.Ip = (VMIP)Addr;
//
// Initialize the stack pointer for the EBC. Get the current system stack
// pointer and adjust it down by the max needed for the interpreter.
@@ -255,60 +256,61 @@ EbcInterpret ( //
// Allocate stack pool
//
- Status = GetEBCStack((EFI_HANDLE)-1, &VmContext.StackPool, &StackIndex);
- if (EFI_ERROR(Status)) {
+ Status = GetEBCStack ((EFI_HANDLE)-1, &VmContext.StackPool, &StackIndex);
+ if (EFI_ERROR (Status)) {
return Status;
}
- VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);
- VmContext.Gpr[0] = (UINT64)(UINTN) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);
+
+ VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
+ VmContext.Gpr[0] = (UINT64)(UINTN)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];
- VmContext.Gpr[0] &= ~((VM_REGISTER)(sizeof (UINTN) - 1));
- VmContext.Gpr[0] -= sizeof (UINTN);
+ VmContext.Gpr[0] &= ~((VM_REGISTER)(sizeof (UINTN) - 1));
+ VmContext.Gpr[0] -= sizeof (UINTN);
//
// Put a magic value in the stack gap, then adjust down again
//
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;
- VmContext.StackMagicPtr = (UINTN *) (UINTN) VmContext.Gpr[0];
- VmContext.LowStackTop = (UINTN) VmContext.Gpr[0];
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;
+ VmContext.StackMagicPtr = (UINTN *)(UINTN)VmContext.Gpr[0];
+ VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];
//
// For IA32, this is where we say our return address is
//
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg16;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg15;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg14;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg13;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg12;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg11;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg10;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg9;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg8;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg7;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg6;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg5;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg4;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg3;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg2;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) Arg1;
- VmContext.Gpr[0] -= 16;
- VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg16;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg15;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg14;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg13;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg12;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg11;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg10;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg9;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg8;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg7;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg6;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg5;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg4;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg3;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg2;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)Arg1;
+ VmContext.Gpr[0] -= 16;
+ VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];
//
// We need to keep track of where the EBC stack starts. This way, if the EBC
@@ -333,11 +335,10 @@ EbcInterpret ( //
// Return the value in Gpr[7] unless there was an error
//
- ReturnEBCStack(StackIndex);
- return (UINT64) VmContext.Gpr[7];
+ ReturnEBCStack (StackIndex);
+ return (UINT64)VmContext.Gpr[7];
}
-
/**
Begin executing an EBC image.
@@ -352,9 +353,9 @@ EbcInterpret ( UINT64
EFIAPI
ExecuteEbcImageEntryPoint (
- IN UINTN EntryPoint,
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN UINTN EntryPoint,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
@@ -373,7 +374,7 @@ ExecuteEbcImageEntryPoint ( //
// Now clear out our context
//
- ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));
+ ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));
//
// Save the image handle so we can track the thunks created for this image
@@ -384,7 +385,7 @@ ExecuteEbcImageEntryPoint ( //
// Set the VM instruction pointer to the correct location in memory.
//
- VmContext.Ip = (VMIP) Addr;
+ VmContext.Ip = (VMIP)Addr;
//
// Initialize the stack pointer for the EBC. Get the current system stack
@@ -394,33 +395,34 @@ ExecuteEbcImageEntryPoint ( //
// Allocate stack pool
//
- Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);
- if (EFI_ERROR(Status)) {
+ Status = GetEBCStack (ImageHandle, &VmContext.StackPool, &StackIndex);
+ if (EFI_ERROR (Status)) {
return Status;
}
- VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);
- VmContext.Gpr[0] = (UINT64)(UINTN) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);
+
+ VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
+ VmContext.Gpr[0] = (UINT64)(UINTN)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];
- VmContext.Gpr[0] -= sizeof (UINTN);
+ VmContext.Gpr[0] -= sizeof (UINTN);
//
// Put a magic value in the stack gap, then adjust down again
//
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;
- VmContext.StackMagicPtr = (UINTN *) (UINTN) VmContext.Gpr[0];
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;
+ VmContext.StackMagicPtr = (UINTN *)(UINTN)VmContext.Gpr[0];
//
// Align the stack on a natural boundary
// VmContext.Gpr[0] &= ~(sizeof(UINTN) - 1);
//
- VmContext.LowStackTop = (UINTN) VmContext.Gpr[0];
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) SystemTable;
- VmContext.Gpr[0] -= sizeof (UINTN);
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) ImageHandle;
+ VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)SystemTable;
+ VmContext.Gpr[0] -= sizeof (UINTN);
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)ImageHandle;
- VmContext.Gpr[0] -= 16;
- VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];
+ VmContext.Gpr[0] -= 16;
+ VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];
//
// VM pushes 16-bytes for return address. Simulate that here.
//
@@ -434,11 +436,10 @@ ExecuteEbcImageEntryPoint ( //
// Return the value in Gpr[7] unless there was an error
//
- ReturnEBCStack(StackIndex);
- return (UINT64) VmContext.Gpr[7];
+ ReturnEBCStack (StackIndex);
+ return (UINT64)VmContext.Gpr[7];
}
-
/**
Create thunks for an EBC image entry point, or an EBC protocol service.
@@ -458,31 +459,32 @@ ExecuteEbcImageEntryPoint ( **/
EFI_STATUS
EbcCreateThunks (
- IN EFI_HANDLE ImageHandle,
- IN VOID *EbcEntryPoint,
- OUT VOID **Thunk,
- IN UINT32 Flags
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk,
+ IN UINT32 Flags
)
{
- UINT8 *Ptr;
- UINT8 *ThunkBase;
- UINT32 Index;
- INT32 ThunkSize;
+ UINT8 *Ptr;
+ UINT8 *ThunkBase;
+ UINT32 Index;
+ INT32 ThunkSize;
//
// Check alignment of pointer to EBC code
//
- if ((UINT32) (UINTN) EbcEntryPoint & 0x01) {
+ if ((UINT32)(UINTN)EbcEntryPoint & 0x01) {
return EFI_INVALID_PARAMETER;
}
- ThunkSize = sizeof(mInstructionBufferTemplate);
+ ThunkSize = sizeof (mInstructionBufferTemplate);
- Ptr = EbcAllocatePoolForThunk (sizeof(mInstructionBufferTemplate));
+ Ptr = EbcAllocatePoolForThunk (sizeof (mInstructionBufferTemplate));
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Print(L"Allocate TH: 0x%X\n", (UINT32)Ptr);
//
@@ -493,20 +495,21 @@ EbcCreateThunks ( //
// Give them the address of our buffer we're going to fix up
//
- *Thunk = (VOID *) Ptr;
+ *Thunk = (VOID *)Ptr;
//
// Copy whole thunk instruction buffer template
//
- CopyMem (Ptr, mInstructionBufferTemplate, sizeof(mInstructionBufferTemplate));
+ CopyMem (Ptr, mInstructionBufferTemplate, sizeof (mInstructionBufferTemplate));
//
// Patch EbcEntryPoint and EbcLLEbcInterpret
//
- for (Index = 0; Index < sizeof(mInstructionBufferTemplate) - sizeof(UINTN); Index++) {
+ for (Index = 0; Index < sizeof (mInstructionBufferTemplate) - sizeof (UINTN); Index++) {
if (*(UINTN *)&Ptr[Index] == EBC_ENTRYPOINT_SIGNATURE) {
*(UINTN *)&Ptr[Index] = (UINTN)EbcEntryPoint;
}
+
if (*(UINTN *)&Ptr[Index] == EBC_LL_EBC_ENTRYPOINT_SIGNATURE) {
if ((Flags & FLAG_THUNK_ENTRY_POINT) != 0) {
*(UINTN *)&Ptr[Index] = (UINTN)EbcLLExecuteEbcImageEntryPoint;
@@ -520,7 +523,7 @@ EbcCreateThunks ( // Add the thunk to the list for this image. Do this last since the add
// function flushes the cache for us.
//
- EbcAddImageThunk (ImageHandle, (VOID *) ThunkBase, ThunkSize);
+ EbcAddImageThunk (ImageHandle, (VOID *)ThunkBase, ThunkSize);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c index 25ca8dbc4c..f9def55158 100644 --- a/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c @@ -17,54 +17,54 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // based on whether or not a debugger is present, and other
// platform-specific configurations.
//
-#define VM_STACK_SIZE (1024 * 8)
+#define VM_STACK_SIZE (1024 * 8)
-#define STACK_REMAIN_SIZE (1024 * 4)
+#define STACK_REMAIN_SIZE (1024 * 4)
//
// This is instruction buffer used to create EBC thunk
//
-#define EBC_ENTRYPOINT_SIGNATURE 0xAFAFAFAFAFAFAFAFull
-#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE 0xFAFAFAFAFAFAFAFAull
+#define EBC_ENTRYPOINT_SIGNATURE 0xAFAFAFAFAFAFAFAFull
+#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE 0xFAFAFAFAFAFAFAFAull
UINT8 mInstructionBufferTemplate[] = {
//
// Add a magic code here to help the VM recognize the thunk..
// mov rax, 0xca112ebcca112ebc => 48 B8 BC 2E 11 CA BC 2E 11 CA
//
- 0x48, 0xB8, 0xBC, 0x2E, 0x11, 0xCA, 0xBC, 0x2E, 0x11, 0xCA,
+ 0x48, 0xB8, 0xBC, 0x2E, 0x11, 0xCA, 0xBC, 0x2E, 0x11, 0xCA,
//
// Add code bytes to load up a processor register with the EBC entry point.
// mov r10, EbcEntryPoint => 49 BA XX XX XX XX XX XX XX XX (To be fixed at runtime)
// These 8 bytes of the thunk entry is the address of the EBC
// entry point.
//
- 0x49, 0xBA,
- (UINT8)(EBC_ENTRYPOINT_SIGNATURE & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),
- (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),
+ 0x49, 0xBA,
+ (UINT8)(EBC_ENTRYPOINT_SIGNATURE & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),
+ (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),
//
// Stick in a load of r11 with the address of appropriate VM function.
// mov r11, EbcLLEbcInterpret => 49 BB XX XX XX XX XX XX XX XX (To be fixed at runtime)
//
- 0x49, 0xBB,
- (UINT8)(EBC_LL_EBC_ENTRYPOINT_SIGNATURE & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),
- (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),
+ 0x49, 0xBB,
+ (UINT8)(EBC_LL_EBC_ENTRYPOINT_SIGNATURE & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),
+ (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),
//
// Stick in jump opcode bytes
// jmp r11 => 41 FF E3
//
- 0x41, 0xFF, 0xE3,
+ 0x41, 0xFF, 0xE3,
};
/**
@@ -102,20 +102,19 @@ EbcLLExecuteEbcImageEntryPoint ( **/
VOID
PushU64 (
- IN VM_CONTEXT *VmPtr,
- IN UINT64 Arg
+ IN VM_CONTEXT *VmPtr,
+ IN UINT64 Arg
)
{
//
// Advance the VM stack down, and then copy the argument to the stack.
// Hope it's aligned.
//
- VmPtr->Gpr[0] -= sizeof (UINT64);
- *(UINT64 *) VmPtr->Gpr[0] = Arg;
+ VmPtr->Gpr[0] -= sizeof (UINT64);
+ *(UINT64 *)VmPtr->Gpr[0] = Arg;
return;
}
-
/**
Begin executing an EBC image.
@@ -147,23 +146,23 @@ PushU64 ( UINT64
EFIAPI
EbcInterpret (
- IN UINTN EntryPoint,
- IN UINTN Arg1,
- IN UINTN Arg2,
- IN UINTN Arg3,
- IN UINTN Arg4,
- IN UINTN Arg5,
- IN UINTN Arg6,
- IN UINTN Arg7,
- IN UINTN Arg8,
- IN UINTN Arg9,
- IN UINTN Arg10,
- IN UINTN Arg11,
- IN UINTN Arg12,
- IN UINTN Arg13,
- IN UINTN Arg14,
- IN UINTN Arg15,
- IN UINTN Arg16
+ IN UINTN EntryPoint,
+ IN UINTN Arg1,
+ IN UINTN Arg2,
+ IN UINTN Arg3,
+ IN UINTN Arg4,
+ IN UINTN Arg5,
+ IN UINTN Arg6,
+ IN UINTN Arg7,
+ IN UINTN Arg8,
+ IN UINTN Arg9,
+ IN UINTN Arg10,
+ IN UINTN Arg11,
+ IN UINTN Arg12,
+ IN UINTN Arg13,
+ IN UINTN Arg14,
+ IN UINTN Arg15,
+ IN UINTN Arg16
)
{
//
@@ -182,12 +181,12 @@ EbcInterpret ( //
// Now clear out our context
//
- ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));
+ ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));
//
// Set the VM instruction pointer to the correct location in memory.
//
- VmContext.Ip = (VMIP) Addr;
+ VmContext.Ip = (VMIP)Addr;
//
// Initialize the stack pointer for the EBC. Get the current system stack
@@ -198,14 +197,15 @@ EbcInterpret ( // Adjust the VM's stack pointer down.
//
- Status = GetEBCStack((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);
- if (EFI_ERROR(Status)) {
+ Status = GetEBCStack ((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);
+ if (EFI_ERROR (Status)) {
return Status;
}
- VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);
- VmContext.Gpr[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);
- VmContext.HighStackBottom = (UINTN) VmContext.Gpr[0];
- VmContext.Gpr[0] -= sizeof (UINTN);
+
+ VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
+ VmContext.Gpr[0] = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
+ VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];
+ VmContext.Gpr[0] -= sizeof (UINTN);
//
// Align the stack on a natural boundary.
@@ -215,46 +215,46 @@ EbcInterpret ( //
// Put a magic value in the stack gap, then adjust down again.
//
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;
- VmContext.StackMagicPtr = (UINTN *) (UINTN) VmContext.Gpr[0];
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;
+ VmContext.StackMagicPtr = (UINTN *)(UINTN)VmContext.Gpr[0];
//
// The stack upper to LowStackTop is belong to the VM.
//
- VmContext.LowStackTop = (UINTN) VmContext.Gpr[0];
+ VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];
//
// For the worst case, assume there are 4 arguments passed in registers, store
// them to VM's stack.
//
- PushU64 (&VmContext, (UINT64) Arg16);
- PushU64 (&VmContext, (UINT64) Arg15);
- PushU64 (&VmContext, (UINT64) Arg14);
- PushU64 (&VmContext, (UINT64) Arg13);
- PushU64 (&VmContext, (UINT64) Arg12);
- PushU64 (&VmContext, (UINT64) Arg11);
- PushU64 (&VmContext, (UINT64) Arg10);
- PushU64 (&VmContext, (UINT64) Arg9);
- PushU64 (&VmContext, (UINT64) Arg8);
- PushU64 (&VmContext, (UINT64) Arg7);
- PushU64 (&VmContext, (UINT64) Arg6);
- PushU64 (&VmContext, (UINT64) Arg5);
- PushU64 (&VmContext, (UINT64) Arg4);
- PushU64 (&VmContext, (UINT64) Arg3);
- PushU64 (&VmContext, (UINT64) Arg2);
- PushU64 (&VmContext, (UINT64) Arg1);
+ PushU64 (&VmContext, (UINT64)Arg16);
+ PushU64 (&VmContext, (UINT64)Arg15);
+ PushU64 (&VmContext, (UINT64)Arg14);
+ PushU64 (&VmContext, (UINT64)Arg13);
+ PushU64 (&VmContext, (UINT64)Arg12);
+ PushU64 (&VmContext, (UINT64)Arg11);
+ PushU64 (&VmContext, (UINT64)Arg10);
+ PushU64 (&VmContext, (UINT64)Arg9);
+ PushU64 (&VmContext, (UINT64)Arg8);
+ PushU64 (&VmContext, (UINT64)Arg7);
+ PushU64 (&VmContext, (UINT64)Arg6);
+ PushU64 (&VmContext, (UINT64)Arg5);
+ PushU64 (&VmContext, (UINT64)Arg4);
+ PushU64 (&VmContext, (UINT64)Arg3);
+ PushU64 (&VmContext, (UINT64)Arg2);
+ PushU64 (&VmContext, (UINT64)Arg1);
//
// Interpreter assumes 64-bit return address is pushed on the stack.
// The x64 does not do this so pad the stack accordingly.
//
- PushU64 (&VmContext, (UINT64) 0);
- PushU64 (&VmContext, (UINT64) 0x1234567887654321ULL);
+ PushU64 (&VmContext, (UINT64)0);
+ PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);
//
// For x64, this is where we say our return address is
//
- VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];
+ VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];
//
// We need to keep track of where the EBC stack starts. This way, if the EBC
@@ -279,11 +279,10 @@ EbcInterpret ( //
// Return the value in Gpr[7] unless there was an error
//
- ReturnEBCStack(StackIndex);
- return (UINT64) VmContext.Gpr[7];
+ ReturnEBCStack (StackIndex);
+ return (UINT64)VmContext.Gpr[7];
}
-
/**
Begin executing an EBC image.
@@ -298,9 +297,9 @@ EbcInterpret ( UINT64
EFIAPI
ExecuteEbcImageEntryPoint (
- IN UINTN EntryPoint,
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN UINTN EntryPoint,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
@@ -319,7 +318,7 @@ ExecuteEbcImageEntryPoint ( //
// Now clear out our context
//
- ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));
+ ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));
//
// Save the image handle so we can track the thunks created for this image
@@ -330,52 +329,52 @@ ExecuteEbcImageEntryPoint ( //
// Set the VM instruction pointer to the correct location in memory.
//
- VmContext.Ip = (VMIP) Addr;
+ VmContext.Ip = (VMIP)Addr;
//
// Initialize the stack pointer for the EBC. Get the current system stack
// pointer and adjust it down by the max needed for the interpreter.
//
- Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);
- if (EFI_ERROR(Status)) {
+ Status = GetEBCStack (ImageHandle, &VmContext.StackPool, &StackIndex);
+ if (EFI_ERROR (Status)) {
return Status;
}
- VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);
- VmContext.Gpr[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);
- VmContext.HighStackBottom = (UINTN) VmContext.Gpr[0];
- VmContext.Gpr[0] -= sizeof (UINTN);
+ VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
+ VmContext.Gpr[0] = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
+ VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];
+ VmContext.Gpr[0] -= sizeof (UINTN);
//
// Put a magic value in the stack gap, then adjust down again
//
- *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;
- VmContext.StackMagicPtr = (UINTN *) (UINTN) VmContext.Gpr[0];
+ *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;
+ VmContext.StackMagicPtr = (UINTN *)(UINTN)VmContext.Gpr[0];
//
// Align the stack on a natural boundary
- VmContext.Gpr[0] &= ~(VM_REGISTER)(sizeof(UINTN) - 1);
+ VmContext.Gpr[0] &= ~(VM_REGISTER)(sizeof (UINTN) - 1);
//
- VmContext.LowStackTop = (UINTN) VmContext.Gpr[0];
+ VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];
//
// Simply copy the image handle and system table onto the EBC stack.
// Greatly simplifies things by not having to spill the args.
//
- PushU64 (&VmContext, (UINT64) SystemTable);
- PushU64 (&VmContext, (UINT64) ImageHandle);
+ PushU64 (&VmContext, (UINT64)SystemTable);
+ PushU64 (&VmContext, (UINT64)ImageHandle);
//
// VM pushes 16-bytes for return address. Simulate that here.
//
- PushU64 (&VmContext, (UINT64) 0);
- PushU64 (&VmContext, (UINT64) 0x1234567887654321ULL);
+ PushU64 (&VmContext, (UINT64)0);
+ PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);
//
// For x64, this is where we say our return address is
//
- VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];
+ VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];
//
// Entry function needn't access high stack context, simply
@@ -391,11 +390,10 @@ ExecuteEbcImageEntryPoint ( //
// Return the value in Gpr[7] unless there was an error
//
- ReturnEBCStack(StackIndex);
- return (UINT64) VmContext.Gpr[7];
+ ReturnEBCStack (StackIndex);
+ return (UINT64)VmContext.Gpr[7];
}
-
/**
Create thunks for an EBC image entry point, or an EBC protocol service.
@@ -415,31 +413,32 @@ ExecuteEbcImageEntryPoint ( **/
EFI_STATUS
EbcCreateThunks (
- IN EFI_HANDLE ImageHandle,
- IN VOID *EbcEntryPoint,
- OUT VOID **Thunk,
- IN UINT32 Flags
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk,
+ IN UINT32 Flags
)
{
- UINT8 *Ptr;
- UINT8 *ThunkBase;
- UINT32 Index;
- INT32 ThunkSize;
+ UINT8 *Ptr;
+ UINT8 *ThunkBase;
+ UINT32 Index;
+ INT32 ThunkSize;
//
// Check alignment of pointer to EBC code
//
- if ((UINT32) (UINTN) EbcEntryPoint & 0x01) {
+ if ((UINT32)(UINTN)EbcEntryPoint & 0x01) {
return EFI_INVALID_PARAMETER;
}
- ThunkSize = sizeof(mInstructionBufferTemplate);
+ ThunkSize = sizeof (mInstructionBufferTemplate);
- Ptr = EbcAllocatePoolForThunk (sizeof(mInstructionBufferTemplate));
+ Ptr = EbcAllocatePoolForThunk (sizeof (mInstructionBufferTemplate));
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Print(L"Allocate TH: 0x%X\n", (UINT32)Ptr);
//
@@ -450,20 +449,21 @@ EbcCreateThunks ( //
// Give them the address of our buffer we're going to fix up
//
- *Thunk = (VOID *) Ptr;
+ *Thunk = (VOID *)Ptr;
//
// Copy whole thunk instruction buffer template
//
- CopyMem (Ptr, mInstructionBufferTemplate, sizeof(mInstructionBufferTemplate));
+ CopyMem (Ptr, mInstructionBufferTemplate, sizeof (mInstructionBufferTemplate));
//
// Patch EbcEntryPoint and EbcLLEbcInterpret
//
- for (Index = 0; Index < sizeof(mInstructionBufferTemplate) - sizeof(UINTN); Index++) {
+ for (Index = 0; Index < sizeof (mInstructionBufferTemplate) - sizeof (UINTN); Index++) {
if (*(UINTN *)&Ptr[Index] == EBC_ENTRYPOINT_SIGNATURE) {
*(UINTN *)&Ptr[Index] = (UINTN)EbcEntryPoint;
}
+
if (*(UINTN *)&Ptr[Index] == EBC_LL_EBC_ENTRYPOINT_SIGNATURE) {
if ((Flags & FLAG_THUNK_ENTRY_POINT) != 0) {
*(UINTN *)&Ptr[Index] = (UINTN)EbcLLExecuteEbcImageEntryPoint;
@@ -477,12 +477,11 @@ EbcCreateThunks ( // Add the thunk to the list for this image. Do this last since the add
// function flushes the cache for us.
//
- EbcAddImageThunk (ImageHandle, (VOID *) ThunkBase, ThunkSize);
+ EbcAddImageThunk (ImageHandle, (VOID *)ThunkBase, ThunkSize);
return EFI_SUCCESS;
}
-
/**
This function is called to execute an EBC CALLEX instruction.
The function check the callee's content to see whether it is common native
@@ -500,60 +499,62 @@ EbcCreateThunks ( **/
VOID
EbcLLCALLEX (
- IN VM_CONTEXT *VmPtr,
- IN UINTN FuncAddr,
- IN UINTN NewStackPointer,
- IN VOID *FramePtr,
- IN UINT8 Size
+ IN VM_CONTEXT *VmPtr,
+ IN UINTN FuncAddr,
+ IN UINTN NewStackPointer,
+ IN VOID *FramePtr,
+ IN UINT8 Size
)
{
- UINTN IsThunk;
- UINTN TargetEbcAddr;
- UINT8 InstructionBuffer[sizeof(mInstructionBufferTemplate)];
- UINTN Index;
- UINTN IndexOfEbcEntrypoint;
-
- IsThunk = 1;
- TargetEbcAddr = 0;
+ UINTN IsThunk;
+ UINTN TargetEbcAddr;
+ UINT8 InstructionBuffer[sizeof (mInstructionBufferTemplate)];
+ UINTN Index;
+ UINTN IndexOfEbcEntrypoint;
+
+ IsThunk = 1;
+ TargetEbcAddr = 0;
IndexOfEbcEntrypoint = 0;
//
// Processor specific code to check whether the callee is a thunk to EBC.
//
- CopyMem (InstructionBuffer, (VOID *)FuncAddr, sizeof(InstructionBuffer));
+ CopyMem (InstructionBuffer, (VOID *)FuncAddr, sizeof (InstructionBuffer));
//
// Fill the signature according to mInstructionBufferTemplate
//
- for (Index = 0; Index < sizeof(mInstructionBufferTemplate) - sizeof(UINTN); Index++) {
+ for (Index = 0; Index < sizeof (mInstructionBufferTemplate) - sizeof (UINTN); Index++) {
if (*(UINTN *)&mInstructionBufferTemplate[Index] == EBC_ENTRYPOINT_SIGNATURE) {
*(UINTN *)&InstructionBuffer[Index] = EBC_ENTRYPOINT_SIGNATURE;
- IndexOfEbcEntrypoint = Index;
+ IndexOfEbcEntrypoint = Index;
}
+
if (*(UINTN *)&mInstructionBufferTemplate[Index] == EBC_LL_EBC_ENTRYPOINT_SIGNATURE) {
*(UINTN *)&InstructionBuffer[Index] = EBC_LL_EBC_ENTRYPOINT_SIGNATURE;
}
}
+
//
// Check if we need thunk to native
//
- if (CompareMem (InstructionBuffer, mInstructionBufferTemplate, sizeof(mInstructionBufferTemplate)) != 0) {
+ if (CompareMem (InstructionBuffer, mInstructionBufferTemplate, sizeof (mInstructionBufferTemplate)) != 0) {
IsThunk = 0;
}
- if (IsThunk == 1){
+ if (IsThunk == 1) {
//
// The callee is a thunk to EBC, adjust the stack pointer down 16 bytes and
// put our return address and frame pointer on the VM stack.
// Then set the VM's IP to new EBC code.
//
VmPtr->Gpr[0] -= 8;
- VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);
- VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];
- VmPtr->Gpr[0] -= 8;
- VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));
+ VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], (UINTN)FramePtr);
+ VmPtr->FramePtr = (VOID *)(UINTN)VmPtr->Gpr[0];
+ VmPtr->Gpr[0] -= 8;
+ VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], (UINT64)(UINTN)(VmPtr->Ip + Size));
- CopyMem (&TargetEbcAddr, (UINT8 *)FuncAddr + IndexOfEbcEntrypoint, sizeof(UINTN));
- VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;
+ CopyMem (&TargetEbcAddr, (UINT8 *)FuncAddr + IndexOfEbcEntrypoint, sizeof (UINTN));
+ VmPtr->Ip = (VMIP)(UINTN)TargetEbcAddr;
} else {
//
// The callee is not a thunk to EBC, call native code,
@@ -567,4 +568,3 @@ EbcLLCALLEX ( VmPtr->Ip += Size;
}
}
-
|