X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FLibrary%2FPeiDxeDebugLibReportStatusCode%2FDebugLib.c;h=980255165dffcec0ec3d513564801e0fb654f1f0;hb=6bfbb5f0e09c3fd70e0df5300dfed2e734c4a230;hp=4855c925c1249d6c049c5b07b7984832db392019;hpb=7d2beb7e11441c38ad0b559fd2042e9de510515b;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c index 4855c925c1..980255165d 100644 --- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c +++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c @@ -1,6 +1,9 @@ /** @file Debug Library based on report status code library. + Note that if the debug message length is larger than the maximum allowable + record length, then the debug message will be ignored directly. + Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -12,9 +15,8 @@ **/ - - #include + #include #include @@ -33,6 +35,9 @@ If Format is NULL, then ASSERT(). + If the length of the message string specificed by Format is larger than the maximum allowable + record length, then directly return and not print it. + @param ErrorLevel The error level of the debug message. @param Format Format string for the debug message to print. @param ... Variable argument list whose contents are accessed @@ -54,7 +59,6 @@ DebugPrint ( BASE_LIST BaseListMarker; CHAR8 *FormatString; BOOLEAN Long; - BOOLEAN Done; // // If Format is NULL, then ASSERT(). @@ -69,9 +73,23 @@ DebugPrint ( } // - // Compute the total size of the record + // Compute the total size of the record. + // Note that the passing-in format string and variable parameters will be constructed to + // the following layout: + // + // Buffer->|------------------------| + // | Padding | 4 bytes + // DebugInfo->|------------------------| + // | EFI_DEBUG_INFO | sizeof(EFI_DEBUG_INFO) + // BaseListMarker->|------------------------| + // | ... | + // | variable arguments | 12 * sizeof (UINT64) + // | ... | + // |------------------------| + // | Format String | + // |------------------------|<- (UINT8 *)Buffer + sizeof(Buffer) // - TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format); + TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format); // // If the TotalSize is larger than the maximum record size, then return @@ -86,7 +104,7 @@ DebugPrint ( // Here we skip the first 4 bytes of Buffer, because we must ensure BaseListMarker is // 64-bit aligned, otherwise retrieving 64-bit parameter from BaseListMarker will cause // exception on IPF. Buffer starts at 64-bit aligned address, so skipping 4 types (sizeof(EFI_DEBUG_INFO)) - // just makes addess of BaseListMarker, which follows DebugInfo, 64-bit aligned. + // just makes address of BaseListMarker, which follows DebugInfo, 64-bit aligned. // DebugInfo = (EFI_DEBUG_INFO *)(Buffer) + 1; DebugInfo->ErrorLevel = (UINT32)ErrorLevel; @@ -115,91 +133,66 @@ DebugPrint ( // // Parse Flags and Width // - for (Done = FALSE; !Done; ) { - Format++; - switch (*Format) { - case '.': - case '-': - case '+': - case ' ': - case ',': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': + for (Format++; TRUE; Format++) { + if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') { // // These characters in format field are omitted. // - break; - case 'L': - case 'l': + continue; + } + if (*Format >= '0' && *Format <= '9') { + // + // These characters in format field are omitted. + // + continue; + } + if (*Format == 'L' || *Format == 'l') { // // 'L" or "l" in format field means the number being printed is a UINT64 // Long = TRUE; - break; - case '*': + continue; + } + if (*Format == '*') { // // '*' in format field means the precision of the field is specified by // a UINTN argument in the argument list. // BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN); - break; - case '\0': + continue; + } + if (*Format == '\0') { // // Make no output if Format string terminates unexpectedly when // looking up for flag, width, precision and type. // Format--; - // - // break skipped on purpose. - // - default: - // - // When valid argument type detected or format string terminates unexpectedly, - // the inner loop is done. - // - Done = TRUE; - break; } - } - + // + // When valid argument type detected or format string terminates unexpectedly, + // the inner loop is done. + // + break; + } + // // Pack variable arguments into the storage area following EFI_DEBUG_INFO. // - switch (*Format) { - case 'p': - if (sizeof (VOID *) > 4) { - Long = TRUE; - } - case 'X': - case 'x': - case 'd': + if ((*Format == 'p') && (sizeof (VOID *) > 4)) { + Long = TRUE; + } + if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd') { if (Long) { BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64); } else { BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int); } - break; - case 's': - case 'S': - case 'a': - case 'g': - case 't': + } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') { BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *); - break; - case 'c': + } else if (*Format == 'c') { BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN); - break; - case 'r': + } else if (*Format == 'r') { BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS); - break; } //