#include "EdbCommon.h"\r
#include "EdbSupport.h"\r
\r
+/**\r
+\r
+ The function that displays the utility usage message.\r
+\r
+**/\r
VOID\r
PrintUsage (\r
VOID\r
return;\r
}\r
\r
+/**\r
+\r
+ The function is to show some information.\r
+\r
+ @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL.\r
+\r
+**/\r
VOID\r
EdbShowInfo (\r
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration\r
return ;\r
}\r
\r
+/**\r
+\r
+ EdbConfigBreak function.\r
+\r
+ @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL.\r
+ @param Command Point to the command.\r
+ @param CommandArg The argument for this command.\r
+\r
+**/\r
VOID\r
EdbConfigBreak (\r
EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration,\r
#define EDB_INSTRUCTION_CONTENT_MAX_LENGTH 30\r
#define EDB_INSTRUCTION_CONTENT_MAX_SIZE (EDB_INSTRUCTION_CONTENT_MAX_LENGTH * sizeof(CHAR16))\r
\r
+/**\r
+\r
+ Set offset for Instruction name and content.\r
+\r
+ @param InstructionNameOffset - Instruction name offset\r
+ @param InstructionContentOffset - Instruction content offset\r
+\r
+**/\r
VOID\r
EdbSetOffset (\r
IN UINTN InstructionNameOffset,\r
IN UINTN InstructionContentOffset\r
);\r
\r
+/**\r
+\r
+ Pre instruction string construction.\r
+\r
+ @return Instruction string\r
+\r
+**/\r
CHAR16 *\r
EdbPreInstructionString (\r
VOID\r
);\r
\r
+/**\r
+\r
+ Post instruction string construction.\r
+\r
+ @return Instruction string\r
+\r
+**/\r
CHAR16 *\r
EdbPostInstructionString (\r
VOID\r
);\r
\r
+/**\r
+\r
+ Print the instruction name.\r
+\r
+ @param Name - instruction name\r
+\r
+ @return Instruction name offset\r
+\r
+**/\r
UINTN\r
EdbPrintInstructionName (\r
IN CHAR16 *Name\r
);\r
\r
+/**\r
+\r
+ Get Sign, NaturalUnits, and ConstantUnits of the WORD data.\r
+\r
+ @param Data16 - WORD data\r
+ @param NaturalUnits - Natural Units of the WORD\r
+ @param ConstantUnits - Constant Units of the WORD\r
+\r
+ @return Sign value of WORD\r
+\r
+**/\r
BOOLEAN\r
EdbGetNaturalIndex16 (\r
IN UINT16 Data16,\r
OUT UINTN *ConstantUnits\r
);\r
\r
+/**\r
+\r
+ Get Sign, NaturalUnits, and ConstantUnits of the DWORD data.\r
+\r
+ @param Data32 - DWORD data\r
+ @param NaturalUnits - Natural Units of the DWORD\r
+ @param ConstantUnits - Constant Units of the DWORD\r
+\r
+ @return Sign value of DWORD\r
+\r
+**/\r
BOOLEAN\r
EdbGetNaturalIndex32 (\r
IN UINT32 Data32,\r
OUT UINTN *ConstantUnits\r
);\r
\r
+/**\r
+\r
+ Get Sign, NaturalUnits, and ConstantUnits of the QWORD data.\r
+\r
+ @param Data64 - QWORD data\r
+ @param NaturalUnits - Natural Units of the QWORD\r
+ @param ConstantUnits - Constant Units of the QWORD\r
+\r
+ @return Sign value of QWORD\r
+\r
+**/\r
BOOLEAN\r
EdbGetNaturalIndex64 (\r
IN UINT64 Data64,\r
OUT UINT64 *ConstantUnits\r
);\r
\r
+/**\r
+\r
+ Print the hexical WORD raw index data to instruction content.\r
+\r
+ @param Data16 - WORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintRawIndexData16 (\r
IN UINT16 Data16\r
);\r
\r
+/**\r
+\r
+ Print the hexical DWORD raw index data to instruction content.\r
+\r
+ @param Data32 - DWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintRawIndexData32 (\r
IN UINT32 Data32\r
);\r
\r
+/**\r
+\r
+ Print the hexical QWORD raw index data to instruction content.\r
+\r
+ @param Data64 - QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintRawIndexData64 (\r
IN UINT64 Data64\r
);\r
\r
+/**\r
+\r
+ Print register 1 in operands.\r
+\r
+ @param Operands - instruction operands\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintRegister1 (\r
IN UINT8 Operands\r
);\r
\r
+/**\r
+\r
+ Print register 2 in operands.\r
+\r
+ @param Operands - instruction operands\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintRegister2 (\r
IN UINT8 Operands\r
);\r
\r
+/**\r
+\r
+ Print dedicated register 1 in operands.\r
+\r
+ @param Operands - instruction operands\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintDedicatedRegister1 (\r
IN UINT8 Operands\r
);\r
\r
+/**\r
+\r
+ Print dedicated register 2 in operands.\r
+\r
+ @param Operands - instruction operands\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintDedicatedRegister2 (\r
IN UINT8 Operands\r
);\r
\r
+/**\r
+\r
+ Print the hexical UINTN index data to instruction content.\r
+\r
+ @param Sign - Signed bit of UINTN data\r
+ @param NaturalUnits - natural units of UINTN data\r
+ @param ConstantUnits - natural units of UINTN data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintIndexData (\r
IN BOOLEAN Sign,\r
IN UINTN ConstantUnits\r
);\r
\r
+/**\r
+\r
+ Print the hexical QWORD index data to instruction content.\r
+\r
+ @param Sign - Signed bit of QWORD data\r
+ @param NaturalUnits - natural units of QWORD data\r
+ @param ConstantUnits - natural units of QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintIndexData64 (\r
IN BOOLEAN Sign,\r
IN UINT64 ConstantUnits\r
);\r
\r
+/**\r
+\r
+ Print the hexical BYTE immediate data to instruction content.\r
+\r
+ @param Data - BYTE data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintImmData8 (\r
IN UINT8 Data\r
);\r
\r
+/**\r
+\r
+ Print the hexical WORD immediate data to instruction content.\r
+\r
+ @param Data - WORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintImmData16 (\r
IN UINT16 Data\r
);\r
\r
+/**\r
+\r
+ Print the hexical DWORD immediate data to instruction content.\r
+\r
+ @param Data - DWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintImmData32 (\r
IN UINT32 Data\r
);\r
\r
+/**\r
+\r
+ Print the hexical QWORD immediate data to instruction content.\r
+\r
+ @param Data - QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintImmData64 (\r
IN UINT64 Data\r
);\r
\r
+/**\r
+\r
+ Print the decimal UINTN immediate data to instruction content.\r
+\r
+ @param Data - UINTN data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintImmDatan (\r
IN UINTN Data\r
);\r
\r
+/**\r
+\r
+ Print the decimal QWORD immediate data to instruction content.\r
+\r
+ @param Data64 - QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintImmData64n (\r
IN UINT64 Data64\r
);\r
\r
+/**\r
+\r
+ Print the hexical BYTE to instruction content.\r
+\r
+ @param Data8 - BYTE data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData8 (\r
IN UINT8 Data8\r
);\r
\r
+/**\r
+\r
+ Print the hexical WORD to instruction content.\r
+\r
+ @param Data16 - WORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData16 (\r
IN UINT16 Data16\r
);\r
\r
+/**\r
+\r
+ Print the hexical DWORD to instruction content.\r
+\r
+ @param Data32 - DWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData32 (\r
IN UINT32 Data32\r
);\r
\r
+/**\r
+\r
+ Print the hexical QWORD to instruction content.\r
+\r
+ @param Data64 - QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData64 (\r
IN UINT64 Data64\r
);\r
\r
+/**\r
+\r
+ Print the decimal unsigned UINTN to instruction content.\r
+\r
+ @param Data - unsigned UINTN data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintDatan (\r
IN UINTN Data\r
);\r
\r
+/**\r
+\r
+ Print the decimal unsigned QWORD to instruction content.\r
+\r
+ @param Data64 - unsigned QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData64n (\r
IN UINT64 Data64\r
);\r
\r
+/**\r
+\r
+ Print the decimal signed BYTE to instruction content.\r
+\r
+ @param Data8 - signed BYTE data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData8s (\r
IN UINT8 Data8\r
);\r
\r
+/**\r
+\r
+ Print the decimal signed WORD to instruction content.\r
+\r
+ @param Data16 - signed WORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData16s (\r
IN UINT16 Data16\r
);\r
\r
+/**\r
+\r
+ Print the decimal signed DWORD to instruction content.\r
+\r
+ @param Data32 - signed DWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData32s (\r
IN UINT32 Data32\r
);\r
\r
+/**\r
+\r
+ Print the decimal signed QWORD to instruction content.\r
+\r
+ @param Data64 - signed QWORD data\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintData64s (\r
IN UINT64 Data64\r
);\r
\r
+/**\r
+\r
+ Print the comma to instruction content.\r
+\r
+ @return Instruction content offset\r
+\r
+**/\r
UINTN\r
EdbPrintComma (\r
VOID\r
);\r
\r
+/**\r
+\r
+ Find the symbol string according to address, then print it.\r
+\r
+ @param Address - instruction address\r
+\r
+ @retval 1 - symbol string is found and printed\r
+ @retval 0 - symbol string not found\r
+\r
+**/\r
UINTN\r
EdbFindAndPrintSymbol (\r
IN UINTN Address\r
);\r
\r
+/**\r
+\r
+ Print the EBC byte code.\r
+\r
+ @param InstructionAddress - instruction address\r
+ @param InstructionNumber - instruction number\r
+\r
+**/\r
VOID\r
EdbPrintRaw (\r
IN EFI_PHYSICAL_ADDRESS InstructionAddress,\r
IN UINTN InstructionNumber\r
);\r
\r
+/**\r
+\r
+ Print the EBC asm code.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param SystemContext - EBC system context.\r
+\r
+ @retval EFI_SUCCESS - show disasm successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbShowDisasm (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN EFI_SYSTEM_CONTEXT SystemContext\r
);\r
\r
+/**\r
+\r
+ Get register value accroding to the system context, and register index.\r
+\r
+ @param SystemContext - EBC system context.\r
+ @param Index - EBC register index\r
+\r
+ @return register value\r
+\r
+**/\r
UINT64\r
GetRegisterValue (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
}\r
}\r
\r
+\r
+/**\r
+ Notify the callback function when an event is triggered.\r
+\r
+ @param Event Indicates the event that invoke this function.\r
+ @param Context Indicates the calling context.\r
+\r
+**/\r
VOID\r
EFIAPI\r
EbcDebuggerBreakEventFunc (\r
@param Handle - The EbcImage handle.\r
\r
**/\r
-\r
VOID\r
EbcDebuggerHookEbcUnloadImage (\r
IN EFI_HANDLE Handle\r
\r
#define EFI_DEBUG_MAX_PRINT_BUFFER (80 * 4)\r
\r
+/**\r
+\r
+ Convert hex string to uint.\r
+\r
+ @param Str - The string\r
+\r
+**/\r
UINTN\r
EFIAPI\r
Xtoi (\r
CHAR16 *Str\r
);\r
\r
+/**\r
+\r
+ Convert hex string to uint.\r
+\r
+ @param Str - The string\r
+\r
+**/\r
UINT64\r
EFIAPI\r
LXtoi (\r
CHAR16 *Str\r
);\r
\r
+/**\r
+\r
+ Convert hex string to uint.\r
+\r
+ @param Str - The string\r
+\r
+**/\r
UINTN\r
EFIAPI\r
Atoi (\r
CHAR16 *Str\r
);\r
\r
+/**\r
+\r
+ Convert hex string to uint.\r
+\r
+ @param Str - The string\r
+\r
+**/\r
UINTN\r
EFIAPI\r
AsciiXtoi (\r
CHAR8 *Str\r
);\r
\r
+/**\r
+\r
+ Convert hex string to uint.\r
+\r
+ @param Str - The string\r
+\r
+**/\r
UINTN\r
EFIAPI\r
AsciiAtoi (\r
CHAR8 *Str\r
);\r
\r
+/**\r
+ Compare the Unicode and Ascii string pointed by String to the string pointed by String2.\r
+\r
+ @param String - Unicode String to process\r
+\r
+ @param String2 - Ascii string to process\r
+\r
+ @return Return a positive integer if String is lexicall greater than String2; Zero if\r
+ the two strings are identical; and a negative interger if String is lexically\r
+ less than String2.\r
+\r
+**/\r
INTN\r
EFIAPI\r
StrCmpUnicodeAndAscii (\r
IN CHAR8 *String2\r
);\r
\r
+/**\r
+\r
+ Compare the Unicode string pointed by String to the string pointed by String2.\r
+\r
+ @param String - Unicode String to process\r
+ @param String2 - Unicode string to process\r
+\r
+ @return Return a positive integer if String is lexically greater than String2; Zero if\r
+ the two strings are identical; and a negative integer if String is lexically\r
+ less than String2.\r
+\r
+**/\r
INTN\r
EFIAPI\r
StriCmp (\r
IN CHAR16 *String2\r
);\r
\r
+/**\r
+\r
+ Compare the Unicode and Ascii string pointed by String to the string pointed by String2.\r
+\r
+ @param String - Unicode String to process\r
+ @param String2 - Ascii string to process\r
+\r
+ @return Return a positive integer if String is lexically greater than String2; Zero if\r
+ the two strings are identical; and a negative integer if String is lexically\r
+ less than String2.\r
+\r
+**/\r
INTN\r
EFIAPI\r
StriCmpUnicodeAndAscii (\r
IN CHAR8 *String2\r
);\r
\r
+/**\r
+\r
+ Verify if the string is end with the sub string.\r
+\r
+ @param Str - The string where to search the sub string\r
+ @param SubStr - The substring.\r
+\r
+**/\r
BOOLEAN\r
EFIAPI\r
StrEndWith (\r
IN CHAR16 *SubStr\r
);\r
\r
+/**\r
+ Duplicate a string.\r
+\r
+ @param Src The string to be duplicated.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrDuplicate (\r
IN CHAR16 *Src\r
);\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNewTokenLine (\r
IN CHAR16 *CharSet\r
);\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNextTokenLine (\r
IN CHAR16 *CharSet\r
);\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNewTokenField (\r
IN CHAR16 *CharSet\r
);\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNextTokenField (\r
IN CHAR16 *CharSet\r
);\r
\r
+/**\r
+\r
+ Patch a character to the end of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForStrTokenAfter (\r
IN CHAR16 Patch\r
);\r
\r
+/**\r
+ Patch a character at the beginning of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForStrTokenBefore (\r
IN CHAR16 Patch\r
);\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNewTokenLine (\r
IN CHAR8 *CharSet\r
);\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNextTokenLine (\r
IN CHAR8 *CharSet\r
);\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNewTokenField (\r
IN CHAR8 *CharSet\r
);\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNextTokenField (\r
IN CHAR8 *CharSet\r
);\r
\r
+/**\r
+\r
+ Patch a character to the end of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForAsciiStrTokenAfter (\r
IN CHAR8 Patch\r
);\r
\r
+/**\r
+ Patch a character at the beginning of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForAsciiStrTokenBefore (\r
);\r
\r
/**\r
-Shell Library.\r
+\r
+ Shell Library.\r
+ Get user input.\r
+\r
+ @param Prompt The prompt string.\r
+ @param InStr Point to the input string.\r
+ @param StrLen The max length of string user can input.\r
+\r
**/\r
VOID\r
EFIAPI\r
IN UINTN StrLen\r
);\r
\r
+/**\r
+\r
+ SetPageBreak.\r
+\r
+**/\r
BOOLEAN\r
EFIAPI\r
SetPageBreak (\r
VOID\r
);\r
\r
+/**\r
+ Print a Unicode string to the output device.\r
+\r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... The variable argument list that contains pointers to Null-\r
+ terminated Unicode strings to be printed\r
+\r
+**/\r
UINTN\r
EFIAPI\r
EDBPrint (\r
...\r
);\r
\r
+/**\r
+ Print a Unicode string to the output buffer.\r
+\r
+ @param Buffer A pointer to the output buffer for the produced Null-terminated\r
+ Unicode string.\r
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... The variable argument list that contains pointers to Null-\r
+ terminated Unicode strings to be printed\r
+\r
+**/\r
UINTN\r
EFIAPI\r
EDBSPrint (\r
...\r
);\r
\r
+/**\r
+ Print a Unicode string to the output buffer with specified offset..\r
+\r
+ @param Buffer A pointer to the output buffer for the produced Null-terminated\r
+ Unicode string.\r
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+ @param Offset The offset of the buffer.\r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... The variable argument list that contains pointers to Null-\r
+ terminated Unicode strings to be printed\r
+\r
+**/\r
UINTN\r
EFIAPI\r
EDBSPrintWithOffset (\r
...\r
);\r
\r
+/**\r
+\r
+ Read a file.\r
+ If ScanFs is FLASE, it will use DebuggerPrivate->Vol as default Fs.\r
+ If ScanFs is TRUE, it will scan all FS and check the file.\r
+ If there is only one file match the name, it will be read.\r
+ If there is more than one file match the name, it will return Error.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param FileName - The file to be read.\r
+ @param BufferSize - The file buffer size\r
+ @param Buffer - The file buffer\r
+ @param ScanFs - Need Scan all FS\r
+\r
+ @retval EFI_SUCCESS - read file successfully\r
+ @retval EFI_NOT_FOUND - file not found\r
+ @retval EFI_NO_MAPPING - there is duplicated files found\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
ReadFileToBuffer (\r
IN BOOLEAN ScanFs\r
);\r
\r
+/**\r
+\r
+ Get file name under this dir with index\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param DirName - The dir to be read.\r
+ @param FileName - The file name pattern under this dir\r
+ @param Index - The file index under this dir\r
+\r
+ @return File Name which match the pattern and index.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
GetFileNameUnderDir (\r
@param Str - The string\r
\r
**/\r
-\r
UINT64\r
EFIAPI\r
LXtoi (\r
return RetVal;\r
}\r
\r
+/**\r
+\r
+ Convert the character to upper case.\r
+\r
+ @param Chr the character to be converted.\r
+\r
+**/\r
STATIC\r
CHAR16\r
UnicodeToUpper (\r
return (Chr >= L'a' && Chr <= L'z') ? Chr - (L'a' - L'A') : Chr;\r
}\r
\r
+/**\r
+\r
+ Convert the character to upper case.\r
+\r
+ @param Chr the character to be converted.\r
+\r
+**/\r
STATIC\r
CHAR8\r
AsciiToUpper (\r
@param CharSet Point to the string to be found.\r
\r
**/\r
-\r
CHAR16 *\r
EFIAPI\r
StrBrk (\r
@param CharSet Point to the string to be found.\r
\r
**/\r
-\r
CHAR16 *\r
EFIAPI\r
StrTokenField (\r
return Begin;\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNewTokenLine (\r
return StrTokenLine (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNextTokenLine (\r
return StrTokenLine (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNewTokenField (\r
return StrTokenField (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNextTokenField (\r
return StrTokenField (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Patch a character to the end of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForStrTokenAfter (\r
return ;\r
}\r
\r
+/**\r
+ Patch a character at the beginning of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForStrTokenBefore (\r
@param CharSet Point to the string to be found.\r
\r
**/\r
-\r
CHAR8 *\r
EFIAPI\r
AsciiStrTokenField (\r
return Begin;\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNewTokenLine (\r
return AsciiStrTokenLine (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNextTokenLine (\r
return AsciiStrTokenLine (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNewTokenField (\r
return AsciiStrTokenField (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNextTokenField (\r
return AsciiStrTokenField (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Patch a character to the end of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForAsciiStrTokenAfter (\r
return ;\r
}\r
\r
+/**\r
+ Patch a character at the beginning of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForAsciiStrTokenBefore (\r
\r
#include "Edb.h"\r
\r
+/**\r
+ Set the current coordinates of the cursor position.\r
+\r
+ @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
+ @param Column The position to set the cursor to.\r
+ @param Row The position to set the cursor to.\r
+ @param LineLength Length of a line.\r
+ @param TotalRow Total row of a screen.\r
+ @param Str Point to the string.\r
+ @param StrPos The position of the string.\r
+ @param Len The length of the string.\r
+\r
+**/\r
VOID\r
EFIAPI\r
SetCursorPosition (\r
CHAR16 mBackupSpace[EFI_DEBUG_INPUS_BUFFER_SIZE];\r
CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE];\r
\r
+/**\r
+\r
+ Get user input.\r
+\r
+ @param Prompt The prompt string.\r
+ @param InStr Point to the input string.\r
+ @param StrLength The max length of string user can input.\r
+\r
+**/\r
VOID\r
EFIAPI\r
Input (\r
return ;\r
}\r
\r
+/**\r
+ Set the current coordinates of the cursor position.\r
+\r
+ @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
+ @param Column The position to set the cursor to.\r
+ @param Row The position to set the cursor to.\r
+ @param LineLength Length of a line.\r
+ @param TotalRow Total row of a screen.\r
+ @param Str Point to the string.\r
+ @param StrPos The position of the string.\r
+ @param Len The length of the string.\r
+\r
+**/\r
VOID\r
EFIAPI\r
SetCursorPosition (\r
ConOut->SetCursorPosition (ConOut, 0, 0);\r
}\r
\r
+/**\r
+\r
+ SetPageBreak.\r
+\r
+**/\r
BOOLEAN\r
EFIAPI\r
SetPageBreak (\r
return OmitPrint;\r
}\r
\r
+/**\r
+ Print a Unicode string to the output device.\r
+\r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... The variable argument list that contains pointers to Null-\r
+ terminated Unicode strings to be printed\r
+\r
+**/\r
UINTN\r
EFIAPI\r
EDBPrint (\r
return Return;\r
}\r
\r
+/**\r
+ Print a Unicode string to the output buffer.\r
+\r
+ @param Buffer A pointer to the output buffer for the produced Null-terminated\r
+ Unicode string.\r
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... The variable argument list that contains pointers to Null-\r
+ terminated Unicode strings to be printed\r
+\r
+**/\r
UINTN\r
EFIAPI\r
EDBSPrint (\r
return Return;\r
}\r
\r
+/**\r
+ Print a Unicode string to the output buffer with specified offset..\r
+\r
+ @param Buffer A pointer to the output buffer for the produced Null-terminated\r
+ Unicode string.\r
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
+ @param Offset The offset of the buffer.\r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... The variable argument list that contains pointers to Null-\r
+ terminated Unicode strings to be printed\r
+\r
+**/\r
UINTN\r
EFIAPI\r
EDBSPrintWithOffset (\r
EdbEbcImageRvaSearchTypeMax,\r
} EDB_EBC_IMAGE_RVA_SEARCH_TYPE;\r
\r
+/**\r
+\r
+ Find symbol by address.\r
+\r
+ @param Address - Symbol address\r
+ @param Type - Search type\r
+ @param RetObject - Symbol object\r
+ @param RetEntry - Symbol entry\r
+\r
+ @return Nearest symbol address\r
+\r
+**/\r
UINTN\r
EbdFindSymbolAddress (\r
IN UINTN Address,\r
OUT EFI_DEBUGGER_SYMBOL_ENTRY **Entry\r
);\r
\r
+/**\r
+\r
+ Load symbol file by name.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param FileName - Symbol file name\r
+ @param BufferSize - Symbol file buffer size\r
+ @param Buffer - Symbol file buffer\r
+\r
+ @retval EFI_SUCCESS - load symbol successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbLoadSymbol (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN VOID *Buffer\r
);\r
\r
+/**\r
+\r
+ Unload symbol file by name.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param FileName - Symbol file name\r
+\r
+ @retval EFI_SUCCESS - unload symbol successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbUnloadSymbol (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN CHAR16 *FileName\r
);\r
\r
+/**\r
+\r
+ Patch symbol RVA.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param FileName - Symbol file name\r
+ @param SearchType - Search type for Object\r
+\r
+ @retval EFI_SUCCESS - Patch symbol RVA successfully\r
+ @retval EFI_NOT_FOUND - Symbol RVA base not found\r
+\r
+**/\r
EFI_STATUS\r
EdbPatchSymbolRVA (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType\r
);\r
\r
+/**\r
+\r
+ Load code.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param MapFileName - Symbol file name\r
+ @param FileName - Code file name\r
+ @param BufferSize - Code file buffer size\r
+ @param Buffer - Code file buffer\r
+\r
+ @retval EFI_SUCCESS - Code loaded successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbLoadCode (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN VOID *Buffer\r
);\r
\r
+/**\r
+\r
+ Unload code.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param MapFileName - Symbol file name\r
+ @param FileName - Code file name\r
+ @param Buffer - Code file buffer\r
+\r
+ @retval EFI_SUCCESS - Code unloaded successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbUnloadCode (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
OUT VOID **Buffer\r
);\r
\r
+/**\r
+\r
+ Add code buffer.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param MapFileName - Symbol file name\r
+ @param CodeFileName - Code file name\r
+ @param SourceBufferSize- Code buffer size\r
+ @param SourceBuffer - Code buffer\r
+\r
+ @retval EFI_SUCCESS - CodeBuffer added successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbAddCodeBuffer (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN VOID *SourceBuffer\r
);\r
\r
+/**\r
+\r
+ Delete code buffer.\r
+\r
+ @param DebuggerPrivate - EBC Debugger private data structure\r
+ @param MapFileName - Symbol file name\r
+ @param CodeFileName - Code file name\r
+ @param SourceBuffer - Code buffer\r
+\r
+ @retval EFI_SUCCESS - CodeBuffer deleted successfully\r
+\r
+**/\r
EFI_STATUS\r
EdbDeleteCodeBuffer (\r
IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
IN VOID *SourceBuffer\r
);\r
\r
+/**\r
+\r
+ Find the symbol string according to address.\r
+\r
+ @param Address - Symbol address\r
+\r
+ @return Symbol string\r
+\r
+**/\r
CHAR8 *\r
FindSymbolStr (\r
IN UINTN Address\r
);\r
\r
+/**\r
+\r
+ Print source.\r
+\r
+ @param Address - Instruction address\r
+ @param IsPrint - Whether need to print\r
+\r
+ @retval 1 - find the source\r
+ @retval 0 - not find the source\r
+\r
+**/\r
UINTN\r
EdbPrintSource (\r
IN UINTN Address,\r
IN BOOLEAN IsPrint\r
);\r
\r
+/**\r
+\r
+ Convert a symbol to an address.\r
+\r
+ @param Symbol - Symbol name\r
+ @param Address - Symbol address\r
+\r
+ @retval EFI_SUCCESS - symbol found and address returned.\r
+ @retval EFI_NOT_FOUND - symbol not found\r
+ @retval EFI_NO_MAPPING - duplicated symbol not found\r
+\r
+**/\r
EFI_STATUS\r
Symboltoi (\r
IN CHAR16 *Symbol,\r
\r
#include "EbcDebuggerHook.h"\r
\r
+/**\r
+\r
+ The hook in InitializeEbcDriver.\r
+\r
+ @param Handle - The EbcDebugProtocol handle.\r
+ @param EbcDebugProtocol - The EbcDebugProtocol interface.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookInit (\r
IN EFI_HANDLE Handle,\r
return;\r
}\r
\r
+/**\r
+\r
+The hook in UnloadImage for EBC Interpreter.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookUnload (\r
VOID\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in EbcUnloadImage.\r
+ Currently do nothing here.\r
+\r
+ @param Handle The EbcImage handle.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookEbcUnloadImage (\r
IN EFI_HANDLE Handle\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteEbcImageEntryPoint.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookExecuteEbcImageEntryPoint (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteEbcImageEntryPoint.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookEbcInterpret (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+ The hook in EbcExecute, before ExecuteFunction.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookExecuteStart (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+ The hook in EbcExecute, after ExecuteFunction.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookExecuteEnd (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLStart (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, after move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLEnd (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, before call EbcLLCALLEX.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLEXStart (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, after call EbcLLCALLEX.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLEXEnd (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteRET, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookRETStart (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteRET, after move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookRETEnd (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMPStart (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP, after move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMPEnd (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP8, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMP8Start (\r
IN VM_CONTEXT *VmPtr\r
return;\r
}\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP8, after move IP..\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMP8End (\r
IN VM_CONTEXT *VmPtr\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
-//\r
-// Hooks in EbcInt.c\r
-//\r
+/**\r
+\r
+ The hook in InitializeEbcDriver.\r
+\r
+ @param Handle - The EbcDebugProtocol handle.\r
+ @param EbcDebugProtocol - The EbcDebugProtocol interface.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookInit (\r
IN EFI_HANDLE Handle,\r
IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol\r
);\r
\r
+/**\r
+\r
+The hook in UnloadImage for EBC Interpreter.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookUnload (\r
VOID\r
);\r
\r
+/**\r
+\r
+ The hook in EbcUnloadImage.\r
+ Currently do nothing here.\r
+\r
+ @param Handle The EbcImage handle.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookEbcUnloadImage (\r
IN EFI_HANDLE Handle\r
);\r
\r
-//\r
-// Hooks in EbcSupport.c\r
-//\r
+\r
+/**\r
+\r
+ Hooks in EbcSupport.c\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookExecuteEbcImageEntryPoint (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteEbcImageEntryPoint.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookEbcInterpret (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
-//\r
-// Hooks in EbcExecute.c\r
-//\r
+\r
+/**\r
+ The hook in EbcExecute, before ExecuteFunction.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookExecuteStart (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+ The hook in EbcExecute, after ExecuteFunction.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookExecuteEnd (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+ The hook in ExecuteCALL, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLStart (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, after move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLEnd (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, before call EbcLLCALLEX.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLEXStart (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteCALL, after call EbcLLCALLEX.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookCALLEXEnd (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteRET, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookRETStart (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteRET, after move IP.\r
+ It will record trace information.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookRETEnd (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+\r
+/**\r
+\r
+ The hook in ExecuteJMP, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMPStart (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP, after move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMPEnd (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP8, before move IP.\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMP8Start (\r
IN VM_CONTEXT *VmPtr\r
);\r
\r
+/**\r
+\r
+ The hook in ExecuteJMP8, after move IP..\r
+\r
+ @param VmPtr - pointer to VM context.\r
+\r
+**/\r
VOID\r
EbcDebuggerHookJMP8End (\r
IN VM_CONTEXT *VmPtr\r