From d138a2e987c51d8225ffaba5b523db82f75269cd Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Mon, 5 Dec 2016 11:33:52 +0800 Subject: MdeModulePkg/EbcDxe: Add comments for functions Cc: Jiewen Yao Cc: Pete Batard Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Jiewen.yao@intel.com --- .../EbcDxe/EbcDebugger/EbcDebuggerConfig.c | 21 ++ .../EbcDxe/EbcDebugger/EdbDisasmSupport.h | 338 +++++++++++++++++++++ .../Universal/EbcDxe/EbcDebugger/EdbHook.c | 9 +- .../Universal/EbcDxe/EbcDebugger/EdbSupport.h | 251 ++++++++++++++- .../EbcDxe/EbcDebugger/EdbSupportString.c | 108 ++++++- .../Universal/EbcDxe/EbcDebugger/EdbSupportUI.c | 71 +++++ .../Universal/EbcDxe/EbcDebugger/EdbSymbol.h | 128 ++++++++ MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c | 117 +++++++ MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h | 129 +++++++- 9 files changed, 1157 insertions(+), 15 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c index 248b1fc6a9..2a123bfc53 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c @@ -18,6 +18,11 @@ #include "EdbCommon.h" #include "EdbSupport.h" +/** + + The function that displays the utility usage message. + +**/ VOID PrintUsage ( VOID @@ -38,6 +43,13 @@ PrintUsage ( return; } +/** + + The function is to show some information. + + @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL. + +**/ VOID EdbShowInfo ( EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration @@ -47,6 +59,15 @@ EdbShowInfo ( return ; } +/** + + EdbConfigBreak function. + + @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL. + @param Command Point to the command. + @param CommandArg The argument for this command. + +**/ VOID EdbConfigBreak ( EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration, diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h index 702673b8df..801cbc1236 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h @@ -33,27 +33,69 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define EDB_INSTRUCTION_CONTENT_MAX_LENGTH 30 #define EDB_INSTRUCTION_CONTENT_MAX_SIZE (EDB_INSTRUCTION_CONTENT_MAX_LENGTH * sizeof(CHAR16)) +/** + + Set offset for Instruction name and content. + + @param InstructionNameOffset - Instruction name offset + @param InstructionContentOffset - Instruction content offset + +**/ VOID EdbSetOffset ( IN UINTN InstructionNameOffset, IN UINTN InstructionContentOffset ); +/** + + Pre instruction string construction. + + @return Instruction string + +**/ CHAR16 * EdbPreInstructionString ( VOID ); +/** + + Post instruction string construction. + + @return Instruction string + +**/ CHAR16 * EdbPostInstructionString ( VOID ); +/** + + Print the instruction name. + + @param Name - instruction name + + @return Instruction name offset + +**/ UINTN EdbPrintInstructionName ( IN CHAR16 *Name ); +/** + + Get Sign, NaturalUnits, and ConstantUnits of the WORD data. + + @param Data16 - WORD data + @param NaturalUnits - Natural Units of the WORD + @param ConstantUnits - Constant Units of the WORD + + @return Sign value of WORD + +**/ BOOLEAN EdbGetNaturalIndex16 ( IN UINT16 Data16, @@ -61,6 +103,17 @@ EdbGetNaturalIndex16 ( OUT UINTN *ConstantUnits ); +/** + + Get Sign, NaturalUnits, and ConstantUnits of the DWORD data. + + @param Data32 - DWORD data + @param NaturalUnits - Natural Units of the DWORD + @param ConstantUnits - Constant Units of the DWORD + + @return Sign value of DWORD + +**/ BOOLEAN EdbGetNaturalIndex32 ( IN UINT32 Data32, @@ -68,6 +121,17 @@ EdbGetNaturalIndex32 ( OUT UINTN *ConstantUnits ); +/** + + Get Sign, NaturalUnits, and ConstantUnits of the QWORD data. + + @param Data64 - QWORD data + @param NaturalUnits - Natural Units of the QWORD + @param ConstantUnits - Constant Units of the QWORD + + @return Sign value of QWORD + +**/ BOOLEAN EdbGetNaturalIndex64 ( IN UINT64 Data64, @@ -75,41 +139,115 @@ EdbGetNaturalIndex64 ( OUT UINT64 *ConstantUnits ); +/** + + Print the hexical WORD raw index data to instruction content. + + @param Data16 - WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintRawIndexData16 ( IN UINT16 Data16 ); +/** + + Print the hexical DWORD raw index data to instruction content. + + @param Data32 - DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintRawIndexData32 ( IN UINT32 Data32 ); +/** + + Print the hexical QWORD raw index data to instruction content. + + @param Data64 - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintRawIndexData64 ( IN UINT64 Data64 ); +/** + + Print register 1 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintRegister1 ( IN UINT8 Operands ); +/** + + Print register 2 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintRegister2 ( IN UINT8 Operands ); +/** + + Print dedicated register 1 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintDedicatedRegister1 ( IN UINT8 Operands ); +/** + + Print dedicated register 2 in operands. + + @param Operands - instruction operands + + @return Instruction content offset + +**/ UINTN EdbPrintDedicatedRegister2 ( IN UINT8 Operands ); +/** + + Print the hexical UINTN index data to instruction content. + + @param Sign - Signed bit of UINTN data + @param NaturalUnits - natural units of UINTN data + @param ConstantUnits - natural units of UINTN data + + @return Instruction content offset + +**/ UINTN EdbPrintIndexData ( IN BOOLEAN Sign, @@ -117,6 +255,17 @@ EdbPrintIndexData ( IN UINTN ConstantUnits ); +/** + + Print the hexical QWORD index data to instruction content. + + @param Sign - Signed bit of QWORD data + @param NaturalUnits - natural units of QWORD data + @param ConstantUnits - natural units of QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintIndexData64 ( IN BOOLEAN Sign, @@ -124,108 +273,297 @@ EdbPrintIndexData64 ( IN UINT64 ConstantUnits ); +/** + + Print the hexical BYTE immediate data to instruction content. + + @param Data - BYTE data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData8 ( IN UINT8 Data ); +/** + + Print the hexical WORD immediate data to instruction content. + + @param Data - WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData16 ( IN UINT16 Data ); +/** + + Print the hexical DWORD immediate data to instruction content. + + @param Data - DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData32 ( IN UINT32 Data ); +/** + + Print the hexical QWORD immediate data to instruction content. + + @param Data - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData64 ( IN UINT64 Data ); +/** + + Print the decimal UINTN immediate data to instruction content. + + @param Data - UINTN data + + @return Instruction content offset + +**/ UINTN EdbPrintImmDatan ( IN UINTN Data ); +/** + + Print the decimal QWORD immediate data to instruction content. + + @param Data64 - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintImmData64n ( IN UINT64 Data64 ); +/** + + Print the hexical BYTE to instruction content. + + @param Data8 - BYTE data + + @return Instruction content offset + +**/ UINTN EdbPrintData8 ( IN UINT8 Data8 ); +/** + + Print the hexical WORD to instruction content. + + @param Data16 - WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData16 ( IN UINT16 Data16 ); +/** + + Print the hexical DWORD to instruction content. + + @param Data32 - DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData32 ( IN UINT32 Data32 ); +/** + + Print the hexical QWORD to instruction content. + + @param Data64 - QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData64 ( IN UINT64 Data64 ); +/** + + Print the decimal unsigned UINTN to instruction content. + + @param Data - unsigned UINTN data + + @return Instruction content offset + +**/ UINTN EdbPrintDatan ( IN UINTN Data ); +/** + + Print the decimal unsigned QWORD to instruction content. + + @param Data64 - unsigned QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData64n ( IN UINT64 Data64 ); +/** + + Print the decimal signed BYTE to instruction content. + + @param Data8 - signed BYTE data + + @return Instruction content offset + +**/ UINTN EdbPrintData8s ( IN UINT8 Data8 ); +/** + + Print the decimal signed WORD to instruction content. + + @param Data16 - signed WORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData16s ( IN UINT16 Data16 ); +/** + + Print the decimal signed DWORD to instruction content. + + @param Data32 - signed DWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData32s ( IN UINT32 Data32 ); +/** + + Print the decimal signed QWORD to instruction content. + + @param Data64 - signed QWORD data + + @return Instruction content offset + +**/ UINTN EdbPrintData64s ( IN UINT64 Data64 ); +/** + + Print the comma to instruction content. + + @return Instruction content offset + +**/ UINTN EdbPrintComma ( VOID ); +/** + + Find the symbol string according to address, then print it. + + @param Address - instruction address + + @retval 1 - symbol string is found and printed + @retval 0 - symbol string not found + +**/ UINTN EdbFindAndPrintSymbol ( IN UINTN Address ); +/** + + Print the EBC byte code. + + @param InstructionAddress - instruction address + @param InstructionNumber - instruction number + +**/ VOID EdbPrintRaw ( IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN UINTN InstructionNumber ); +/** + + Print the EBC asm code. + + @param DebuggerPrivate - EBC Debugger private data structure + @param SystemContext - EBC system context. + + @retval EFI_SUCCESS - show disasm successfully + +**/ EFI_STATUS EdbShowDisasm ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_SYSTEM_CONTEXT SystemContext ); +/** + + Get register value accroding to the system context, and register index. + + @param SystemContext - EBC system context. + @param Index - EBC register index + + @return register value + +**/ UINT64 GetRegisterValue ( IN EFI_SYSTEM_CONTEXT SystemContext, diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c index 322dd258d0..7592defec0 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbHook.c @@ -278,6 +278,14 @@ EbcDebuggerPushStepEntry ( } } + +/** + Notify the callback function when an event is triggered. + + @param Event Indicates the event that invoke this function. + @param Context Indicates the calling context. + +**/ VOID EFIAPI EbcDebuggerBreakEventFunc ( @@ -467,7 +475,6 @@ EbcDebuggerHookUnload ( @param Handle - The EbcImage handle. **/ - VOID EbcDebuggerHookEbcUnloadImage ( IN EFI_HANDLE Handle diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h index 8908718edb..68becd6d80 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupport.h @@ -25,36 +25,83 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define EFI_DEBUG_MAX_PRINT_BUFFER (80 * 4) +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI Xtoi ( CHAR16 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINT64 EFIAPI LXtoi ( CHAR16 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI Atoi ( CHAR16 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI AsciiXtoi ( CHAR8 *Str ); +/** + + Convert hex string to uint. + + @param Str - The string + +**/ UINTN EFIAPI AsciiAtoi ( CHAR8 *Str ); +/** + Compare the Unicode and Ascii string pointed by String to the string pointed by String2. + + @param String - Unicode String to process + + @param String2 - Ascii string to process + + @return Return a positive integer if String is lexicall greater than String2; Zero if + the two strings are identical; and a negative interger if String is lexically + less than String2. + +**/ INTN EFIAPI StrCmpUnicodeAndAscii ( @@ -62,6 +109,18 @@ StrCmpUnicodeAndAscii ( IN CHAR8 *String2 ); +/** + + Compare the Unicode string pointed by String to the string pointed by String2. + + @param String - Unicode String to process + @param String2 - Unicode string to process + + @return Return a positive integer if String is lexically greater than String2; Zero if + the two strings are identical; and a negative integer if String is lexically + less than String2. + +**/ INTN EFIAPI StriCmp ( @@ -69,6 +128,18 @@ StriCmp ( IN CHAR16 *String2 ); +/** + + Compare the Unicode and Ascii string pointed by String to the string pointed by String2. + + @param String - Unicode String to process + @param String2 - Ascii string to process + + @return Return a positive integer if String is lexically greater than String2; Zero if + the two strings are identical; and a negative integer if String is lexically + less than String2. + +**/ INTN EFIAPI StriCmpUnicodeAndAscii ( @@ -76,6 +147,14 @@ StriCmpUnicodeAndAscii ( IN CHAR8 *String2 ); +/** + + Verify if the string is end with the sub string. + + @param Str - The string where to search the sub string + @param SubStr - The substring. + +**/ BOOLEAN EFIAPI StrEndWith ( @@ -83,12 +162,26 @@ StrEndWith ( IN CHAR16 *SubStr ); +/** + Duplicate a string. + + @param Src The string to be duplicated. + +**/ CHAR16 * EFIAPI StrDuplicate ( IN CHAR16 *Src ); +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenLine ( @@ -96,12 +189,27 @@ StrGetNewTokenLine ( IN CHAR16 *CharSet ); +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenLine ( IN CHAR16 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenField ( @@ -109,12 +217,27 @@ StrGetNewTokenField ( IN CHAR16 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenField ( IN CHAR16 *CharSet ); +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenAfter ( @@ -122,6 +245,13 @@ PatchForStrTokenAfter ( IN CHAR16 Patch ); +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenBefore ( @@ -129,6 +259,14 @@ PatchForStrTokenBefore ( IN CHAR16 Patch ); +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenLine ( @@ -136,12 +274,27 @@ AsciiStrGetNewTokenLine ( IN CHAR8 *CharSet ); +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenLine ( IN CHAR8 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenField ( @@ -149,12 +302,27 @@ AsciiStrGetNewTokenField ( IN CHAR8 *CharSet ); +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenField ( IN CHAR8 *CharSet ); +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenAfter ( @@ -162,6 +330,13 @@ PatchForAsciiStrTokenAfter ( IN CHAR8 Patch ); +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenBefore ( @@ -170,7 +345,14 @@ PatchForAsciiStrTokenBefore ( ); /** -Shell Library. + + Shell Library. + Get user input. + + @param Prompt The prompt string. + @param InStr Point to the input string. + @param StrLen The max length of string user can input. + **/ VOID EFIAPI @@ -180,12 +362,25 @@ Input ( IN UINTN StrLen ); +/** + + SetPageBreak. + +**/ BOOLEAN EFIAPI SetPageBreak ( VOID ); +/** + Print a Unicode string to the output device. + + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBPrint ( @@ -193,6 +388,17 @@ EDBPrint ( ... ); +/** + Print a Unicode string to the output buffer. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrint ( @@ -202,6 +408,18 @@ EDBSPrint ( ... ); +/** + Print a Unicode string to the output buffer with specified offset.. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Offset The offset of the buffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrintWithOffset ( @@ -212,6 +430,25 @@ EDBSPrintWithOffset ( ... ); +/** + + Read a file. + If ScanFs is FLASE, it will use DebuggerPrivate->Vol as default Fs. + If ScanFs is TRUE, it will scan all FS and check the file. + If there is only one file match the name, it will be read. + If there is more than one file match the name, it will return Error. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - The file to be read. + @param BufferSize - The file buffer size + @param Buffer - The file buffer + @param ScanFs - Need Scan all FS + + @retval EFI_SUCCESS - read file successfully + @retval EFI_NOT_FOUND - file not found + @retval EFI_NO_MAPPING - there is duplicated files found + +**/ EFI_STATUS EFIAPI ReadFileToBuffer ( @@ -222,6 +459,18 @@ ReadFileToBuffer ( IN BOOLEAN ScanFs ); +/** + + Get file name under this dir with index + + @param DebuggerPrivate - EBC Debugger private data structure + @param DirName - The dir to be read. + @param FileName - The file name pattern under this dir + @param Index - The file index under this dir + + @return File Name which match the pattern and index. + +**/ CHAR16 * EFIAPI GetFileNameUnderDir ( diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c index bb0626fae7..0a49d2fd57 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c @@ -85,7 +85,6 @@ Xtoi ( @param Str - The string **/ - UINT64 EFIAPI LXtoi ( @@ -308,6 +307,13 @@ AsciiAtoi ( return RetVal; } +/** + + Convert the character to upper case. + + @param Chr the character to be converted. + +**/ STATIC CHAR16 UnicodeToUpper ( @@ -317,6 +323,13 @@ UnicodeToUpper ( return (Chr >= L'a' && Chr <= L'z') ? Chr - (L'a' - L'A') : Chr; } +/** + + Convert the character to upper case. + + @param Chr the character to be converted. + +**/ STATIC CHAR8 AsciiToUpper ( @@ -520,7 +533,6 @@ StrSpn ( @param CharSet Point to the string to be found. **/ - CHAR16 * EFIAPI StrBrk ( @@ -589,7 +601,6 @@ StrTokenLine ( @param CharSet Point to the string to be found. **/ - CHAR16 * EFIAPI StrTokenField ( @@ -621,6 +632,14 @@ StrTokenField ( return Begin; } +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenLine ( @@ -631,6 +650,13 @@ StrGetNewTokenLine ( return StrTokenLine (String, CharSet); } +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenLine ( @@ -640,6 +666,14 @@ StrGetNextTokenLine ( return StrTokenLine (NULL, CharSet); } +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNewTokenField ( @@ -650,6 +684,13 @@ StrGetNewTokenField ( return StrTokenField (String, CharSet); } +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR16 * EFIAPI StrGetNextTokenField ( @@ -659,6 +700,14 @@ StrGetNextTokenField ( return StrTokenField (NULL, CharSet); } +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenAfter ( @@ -689,6 +738,13 @@ PatchForStrTokenAfter ( return ; } +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForStrTokenBefore ( @@ -831,7 +887,6 @@ AsciiStrTokenLine ( @param CharSet Point to the string to be found. **/ - CHAR8 * EFIAPI AsciiStrTokenField ( @@ -863,6 +918,14 @@ AsciiStrTokenField ( return Begin; } +/** + + Find the next token after one or more specified characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenLine ( @@ -873,6 +936,13 @@ AsciiStrGetNewTokenLine ( return AsciiStrTokenLine (String, CharSet); } +/** + + Find the next token after one or more specified characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenLine ( @@ -882,6 +952,14 @@ AsciiStrGetNextTokenLine ( return AsciiStrTokenLine (NULL, CharSet); } +/** + + Find the next token after one specificed characters. + + @param String Point to the string where to find the substring. + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNewTokenField ( @@ -892,6 +970,13 @@ AsciiStrGetNewTokenField ( return AsciiStrTokenField (String, CharSet); } +/** + + Find the next token after one specificed characters. + + @param CharSet Point to the string to be found. + +**/ CHAR8 * EFIAPI AsciiStrGetNextTokenField ( @@ -901,6 +986,14 @@ AsciiStrGetNextTokenField ( return AsciiStrTokenField (NULL, CharSet); } +/** + + Patch a character to the end of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenAfter ( @@ -931,6 +1024,13 @@ PatchForAsciiStrTokenAfter ( return ; } +/** + Patch a character at the beginning of a string. + + @param Buffer The string to be patched. + @param Patch The patch character. + +**/ VOID EFIAPI PatchForAsciiStrTokenBefore ( diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c index 21d0dc9838..14f8627eb5 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c @@ -14,6 +14,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Edb.h" +/** + Set the current coordinates of the cursor position. + + @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + @param Column The position to set the cursor to. + @param Row The position to set the cursor to. + @param LineLength Length of a line. + @param TotalRow Total row of a screen. + @param Str Point to the string. + @param StrPos The position of the string. + @param Len The length of the string. + +**/ VOID EFIAPI SetCursorPosition ( @@ -166,6 +179,15 @@ ConMoveCursorForward ( CHAR16 mBackupSpace[EFI_DEBUG_INPUS_BUFFER_SIZE]; CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE]; +/** + + Get user input. + + @param Prompt The prompt string. + @param InStr Point to the input string. + @param StrLength The max length of string user can input. + +**/ VOID EFIAPI Input ( @@ -514,6 +536,19 @@ Input ( return ; } +/** + Set the current coordinates of the cursor position. + + @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. + @param Column The position to set the cursor to. + @param Row The position to set the cursor to. + @param LineLength Length of a line. + @param TotalRow Total row of a screen. + @param Str Point to the string. + @param StrPos The position of the string. + @param Len The length of the string. + +**/ VOID EFIAPI SetCursorPosition ( @@ -551,6 +586,11 @@ SetCursorPosition ( ConOut->SetCursorPosition (ConOut, 0, 0); } +/** + + SetPageBreak. + +**/ BOOLEAN EFIAPI SetPageBreak ( @@ -620,6 +660,14 @@ SetPageBreak ( return OmitPrint; } +/** + Print a Unicode string to the output device. + + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBPrint ( @@ -645,6 +693,17 @@ EDBPrint ( return Return; } +/** + Print a Unicode string to the output buffer. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrint ( @@ -666,6 +725,18 @@ EDBSPrint ( return Return; } +/** + Print a Unicode string to the output buffer with specified offset.. + + @param Buffer A pointer to the output buffer for the produced Null-terminated + Unicode string. + @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. + @param Offset The offset of the buffer. + @param Format A Null-terminated Unicode format string. + @param ... The variable argument list that contains pointers to Null- + terminated Unicode strings to be printed + +**/ UINTN EFIAPI EDBSPrintWithOffset ( diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h index c4c28582e7..2e8c5e2f4f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.h @@ -39,6 +39,18 @@ typedef enum { EdbEbcImageRvaSearchTypeMax, } EDB_EBC_IMAGE_RVA_SEARCH_TYPE; +/** + + Find symbol by address. + + @param Address - Symbol address + @param Type - Search type + @param RetObject - Symbol object + @param RetEntry - Symbol entry + + @return Nearest symbol address + +**/ UINTN EbdFindSymbolAddress ( IN UINTN Address, @@ -47,6 +59,18 @@ EbdFindSymbolAddress ( OUT EFI_DEBUGGER_SYMBOL_ENTRY **Entry ); +/** + + Load symbol file by name. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - Symbol file name + @param BufferSize - Symbol file buffer size + @param Buffer - Symbol file buffer + + @retval EFI_SUCCESS - load symbol successfully + +**/ EFI_STATUS EdbLoadSymbol ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, @@ -55,12 +79,34 @@ EdbLoadSymbol ( IN VOID *Buffer ); +/** + + Unload symbol file by name. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - Symbol file name + + @retval EFI_SUCCESS - unload symbol successfully + +**/ EFI_STATUS EdbUnloadSymbol ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN CHAR16 *FileName ); +/** + + Patch symbol RVA. + + @param DebuggerPrivate - EBC Debugger private data structure + @param FileName - Symbol file name + @param SearchType - Search type for Object + + @retval EFI_SUCCESS - Patch symbol RVA successfully + @retval EFI_NOT_FOUND - Symbol RVA base not found + +**/ EFI_STATUS EdbPatchSymbolRVA ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, @@ -68,6 +114,19 @@ EdbPatchSymbolRVA ( IN EDB_EBC_IMAGE_RVA_SEARCH_TYPE SearchType ); +/** + + Load code. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param FileName - Code file name + @param BufferSize - Code file buffer size + @param Buffer - Code file buffer + + @retval EFI_SUCCESS - Code loaded successfully + +**/ EFI_STATUS EdbLoadCode ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, @@ -77,6 +136,18 @@ EdbLoadCode ( IN VOID *Buffer ); +/** + + Unload code. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param FileName - Code file name + @param Buffer - Code file buffer + + @retval EFI_SUCCESS - Code unloaded successfully + +**/ EFI_STATUS EdbUnloadCode ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, @@ -85,6 +156,19 @@ EdbUnloadCode ( OUT VOID **Buffer ); +/** + + Add code buffer. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param CodeFileName - Code file name + @param SourceBufferSize- Code buffer size + @param SourceBuffer - Code buffer + + @retval EFI_SUCCESS - CodeBuffer added successfully + +**/ EFI_STATUS EdbAddCodeBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, @@ -94,6 +178,18 @@ EdbAddCodeBuffer ( IN VOID *SourceBuffer ); +/** + + Delete code buffer. + + @param DebuggerPrivate - EBC Debugger private data structure + @param MapFileName - Symbol file name + @param CodeFileName - Code file name + @param SourceBuffer - Code buffer + + @retval EFI_SUCCESS - CodeBuffer deleted successfully + +**/ EFI_STATUS EdbDeleteCodeBuffer ( IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, @@ -102,17 +198,49 @@ EdbDeleteCodeBuffer ( IN VOID *SourceBuffer ); +/** + + Find the symbol string according to address. + + @param Address - Symbol address + + @return Symbol string + +**/ CHAR8 * FindSymbolStr ( IN UINTN Address ); +/** + + Print source. + + @param Address - Instruction address + @param IsPrint - Whether need to print + + @retval 1 - find the source + @retval 0 - not find the source + +**/ UINTN EdbPrintSource ( IN UINTN Address, IN BOOLEAN IsPrint ); +/** + + Convert a symbol to an address. + + @param Symbol - Symbol name + @param Address - Symbol address + + @retval EFI_SUCCESS - symbol found and address returned. + @retval EFI_NOT_FOUND - symbol not found + @retval EFI_NO_MAPPING - duplicated symbol not found + +**/ EFI_STATUS Symboltoi ( IN CHAR16 *Symbol, diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c index 1594cecf16..c5a19342f6 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.c @@ -18,6 +18,14 @@ #include "EbcDebuggerHook.h" +/** + + The hook in InitializeEbcDriver. + + @param Handle - The EbcDebugProtocol handle. + @param EbcDebugProtocol - The EbcDebugProtocol interface. + +**/ VOID EbcDebuggerHookInit ( IN EFI_HANDLE Handle, @@ -27,6 +35,11 @@ EbcDebuggerHookInit ( return; } +/** + +The hook in UnloadImage for EBC Interpreter. + +**/ VOID EbcDebuggerHookUnload ( VOID @@ -35,6 +48,14 @@ EbcDebuggerHookUnload ( return; } +/** + + The hook in EbcUnloadImage. + Currently do nothing here. + + @param Handle The EbcImage handle. + +**/ VOID EbcDebuggerHookEbcUnloadImage ( IN EFI_HANDLE Handle @@ -43,6 +64,13 @@ EbcDebuggerHookEbcUnloadImage ( return; } +/** + + The hook in ExecuteEbcImageEntryPoint. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEbcImageEntryPoint ( IN VM_CONTEXT *VmPtr @@ -51,6 +79,13 @@ EbcDebuggerHookExecuteEbcImageEntryPoint ( return; } +/** + + The hook in ExecuteEbcImageEntryPoint. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookEbcInterpret ( IN VM_CONTEXT *VmPtr @@ -59,6 +94,12 @@ EbcDebuggerHookEbcInterpret ( return; } +/** + The hook in EbcExecute, before ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteStart ( IN VM_CONTEXT *VmPtr @@ -67,6 +108,12 @@ EbcDebuggerHookExecuteStart ( return; } +/** + The hook in EbcExecute, after ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEnd ( IN VM_CONTEXT *VmPtr @@ -75,6 +122,13 @@ EbcDebuggerHookExecuteEnd ( return; } +/** + + The hook in ExecuteCALL, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLStart ( IN VM_CONTEXT *VmPtr @@ -83,6 +137,13 @@ EbcDebuggerHookCALLStart ( return; } +/** + + The hook in ExecuteCALL, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEnd ( IN VM_CONTEXT *VmPtr @@ -91,6 +152,13 @@ EbcDebuggerHookCALLEnd ( return; } +/** + + The hook in ExecuteCALL, before call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXStart ( IN VM_CONTEXT *VmPtr @@ -99,6 +167,13 @@ EbcDebuggerHookCALLEXStart ( return; } +/** + + The hook in ExecuteCALL, after call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXEnd ( IN VM_CONTEXT *VmPtr @@ -107,6 +182,13 @@ EbcDebuggerHookCALLEXEnd ( return; } +/** + + The hook in ExecuteRET, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETStart ( IN VM_CONTEXT *VmPtr @@ -115,6 +197,13 @@ EbcDebuggerHookRETStart ( return; } +/** + + The hook in ExecuteRET, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETEnd ( IN VM_CONTEXT *VmPtr @@ -123,6 +212,13 @@ EbcDebuggerHookRETEnd ( return; } +/** + + The hook in ExecuteJMP, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPStart ( IN VM_CONTEXT *VmPtr @@ -131,6 +227,13 @@ EbcDebuggerHookJMPStart ( return; } +/** + + The hook in ExecuteJMP, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPEnd ( IN VM_CONTEXT *VmPtr @@ -139,6 +242,13 @@ EbcDebuggerHookJMPEnd ( return; } +/** + + The hook in ExecuteJMP8, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8Start ( IN VM_CONTEXT *VmPtr @@ -147,6 +257,13 @@ EbcDebuggerHookJMP8Start ( return; } +/** + + The hook in ExecuteJMP8, after move IP.. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8End ( IN VM_CONTEXT *VmPtr diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h index ad93fd787d..cf81b4ad44 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebuggerHook.h @@ -38,96 +38,207 @@ EbcDebugSignalException ( IN VM_CONTEXT *VmPtr ); -// -// Hooks in EbcInt.c -// +/** + + The hook in InitializeEbcDriver. + + @param Handle - The EbcDebugProtocol handle. + @param EbcDebugProtocol - The EbcDebugProtocol interface. + +**/ VOID EbcDebuggerHookInit ( IN EFI_HANDLE Handle, IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol ); +/** + +The hook in UnloadImage for EBC Interpreter. + +**/ VOID EbcDebuggerHookUnload ( VOID ); +/** + + The hook in EbcUnloadImage. + Currently do nothing here. + + @param Handle The EbcImage handle. + +**/ VOID EbcDebuggerHookEbcUnloadImage ( IN EFI_HANDLE Handle ); -// -// Hooks in EbcSupport.c -// + +/** + + Hooks in EbcSupport.c + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEbcImageEntryPoint ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteEbcImageEntryPoint. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookEbcInterpret ( IN VM_CONTEXT *VmPtr ); -// -// Hooks in EbcExecute.c -// + +/** + The hook in EbcExecute, before ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteStart ( IN VM_CONTEXT *VmPtr ); +/** + The hook in EbcExecute, after ExecuteFunction. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookExecuteEnd ( IN VM_CONTEXT *VmPtr ); +/** + The hook in ExecuteCALL, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteCALL, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEnd ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteCALL, before call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteCALL, after call EbcLLCALLEX. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookCALLEXEnd ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteRET, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteRET, after move IP. + It will record trace information. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookRETEnd ( IN VM_CONTEXT *VmPtr ); + +/** + + The hook in ExecuteJMP, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPStart ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteJMP, after move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMPEnd ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteJMP8, before move IP. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8Start ( IN VM_CONTEXT *VmPtr ); +/** + + The hook in ExecuteJMP8, after move IP.. + + @param VmPtr - pointer to VM context. + +**/ VOID EbcDebuggerHookJMP8End ( IN VM_CONTEXT *VmPtr -- cgit v1.2.3