summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-01 15:05:34 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-01 15:05:34 +0000
commit3d747a890f9e792dc78ca07c7dc4dd571af2e323 (patch)
tree51cbe56e333a9f5f2ee93a30e5f29f6d10005077 /IntelFrameworkModulePkg
parent8e2978b4adc654a20fc7ada49e1631421dc46be2 (diff)
downloadedk2-platforms-3d747a890f9e792dc78ca07c7dc4dd571af2e323.tar.xz
Refactor the code logic to reduce code size for debug tip.
The original switch case statements does not generate space efficient size when optimization is disabled. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9221 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg')
-rw-r--r--IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c92
1 files changed, 33 insertions, 59 deletions
diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index 339a002cd5..20f52f86bf 100644
--- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -53,7 +53,6 @@ DebugPrint (
BASE_LIST BaseListMarker;
CHAR8 *FormatString;
BOOLEAN Long;
- BOOLEAN Done;
//
// If Format is NULL, then ASSERT().
@@ -73,7 +72,7 @@ DebugPrint (
// the following layout:
//
// Buffer->|------------------------|
- // | Pading | 4 bytes
+ // | Padding | 4 bytes
// DebugInfo->|------------------------|
// | EFI_DEBUG_INFO | sizeof(EFI_DEBUG_INFO)
// BaseListMarker->|------------------------|
@@ -99,7 +98,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;
@@ -128,91 +127,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;
}
//