summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-21 06:10:21 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-21 06:10:21 +0000
commitea1b39e617f93f2dd674eb111f101759ea2274b7 (patch)
tree65dfcb96709ab261ee71f5f5cf029fdfd265d5f9 /IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode
parentd4605c23eae95c80804ba592f19b5e8ae2afddb1 (diff)
downloadedk2-platforms-ea1b39e617f93f2dd674eb111f101759ea2274b7.tar.xz
Update PeiDxeDebugLibReportStatusCode library instance to print partial ASSERT message if ASSERT message is too big.
Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13339 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode')
-rw-r--r--IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c81
1 files changed, 54 insertions, 27 deletions
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index f6ab54ed6a..0d794dfca8 100644
--- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -258,44 +258,71 @@ DebugAssert (
{
UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];
EFI_DEBUG_ASSERT_DATA *AssertData;
+ UINTN HeaderSize;
UINTN TotalSize;
CHAR8 *Temp;
UINTN FileNameSize;
UINTN DescriptionSize;
//
- // Make sure it will all fit in the passed in buffer
+ // Get string size
//
- FileNameSize = AsciiStrSize (FileName);
- DescriptionSize = AsciiStrSize (Description);
- TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameSize + DescriptionSize;
- if (TotalSize <= sizeof (Buffer)) {
- //
- // Fill in EFI_DEBUG_ASSERT_DATA
- //
- AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
- AssertData->LineNumber = (UINT32)LineNumber;
-
- //
- // Copy Ascii FileName including NULL.
- //
- Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName);
+ HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA);
+ FileNameSize = AsciiStrSize (FileName);
+ DescriptionSize = AsciiStrSize (Description);
+ //
+ // Make sure it will all fit in the passed in buffer.
+ //
+ if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {
//
- // Copy Ascii Description
+ // FileName + Description is too long to be filled into buffer.
//
- AsciiStrCpy (Temp + FileNameSize, Description);
-
- REPORT_STATUS_CODE_EX (
- (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
- (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
- 0,
- NULL,
- NULL,
- AssertData,
- TotalSize
- );
+ if (HeaderSize + FileNameSize < sizeof (Buffer)) {
+ //
+ // Description has enough buffer to be truncated.
+ //
+ DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize;
+ } else {
+ //
+ // FileName is too long to be filled into buffer.
+ // FileName will be truncated. Reserved one byte for Description NULL terminator.
+ //
+ DescriptionSize = 1;
+ FileNameSize = sizeof (Buffer) - HeaderSize - DescriptionSize;
+ }
}
+
+ //
+ // Fill in EFI_DEBUG_ASSERT_DATA
+ //
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
+ AssertData->LineNumber = (UINT32)LineNumber;
+ TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA);
+
+ //
+ // Copy Ascii FileName including NULL terminator.
+ //
+ Temp = AsciiStrnCpy ((CHAR8 *)(AssertData + 1), FileName, FileNameSize);
+ Temp[FileNameSize - 1] = 0;
+ TotalSize += FileNameSize;
+
+ //
+ // Copy Ascii Description include NULL terminator.
+ //
+ Temp = AsciiStrnCpy (Temp + FileNameSize, Description, DescriptionSize);
+ Temp[DescriptionSize - 1] = 0;
+ TotalSize += DescriptionSize;
+
+ REPORT_STATUS_CODE_EX (
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ 0,
+ NULL,
+ NULL,
+ AssertData,
+ TotalSize
+ );
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings