summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-06-08 05:34:08 +0000
committershenshushi <shenshushi@Edk2>2015-06-08 05:34:08 +0000
commit796fecd84b740f24c26f0791a6cde122517fa2df (patch)
treeb3f2989f7678d181b8445f6013516ce179168a82 /MdeModulePkg
parent94e3eee6e827aa971228044a3b826efa4ebaf1f7 (diff)
downloadedk2-platforms-796fecd84b740f24c26f0791a6cde122517fa2df.tar.xz
MdeModulePkg: Add %u and %lu support for PrintLib and DebugLib.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17570 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c26
-rw-r--r--MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c2
2 files changed, 24 insertions, 4 deletions
diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
index e8a41f76cd..a41f228cc2 100644
--- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
+++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
@@ -177,6 +177,7 @@ DxePrintLibPrint2ProtocolVaListToBaseList (
}
case 'X':
case 'x':
+ case 'u':
case 'd':
if (Long) {
BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
@@ -943,6 +944,7 @@ AsciiValueToString (
#define PRECISION BIT11
#define ARGUMENT_REVERSED BIT12
#define COUNT_ONLY_NO_PRINT BIT13
+#define UNSIGNED_TYPE BIT14
//
// Record date and time information
@@ -1429,10 +1431,18 @@ InternalPrintLibSPrintMarker (
//
// break skipped on purpose
//
+ case 'u':
+ if ((Flags & RADIX_HEX) == 0) {
+ Flags &= ~((UINTN) (PREFIX_SIGN));
+ Flags |= UNSIGNED_TYPE;
+ }
+ //
+ // break skipped on purpose
+ //
case 'd':
if ((Flags & LONG_TYPE) == 0) {
//
- // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
// This assumption is made so the format string definition is compatible with the ANSI C
// Specification for formatted strings. It is recommended that the Base Types be used
// everywhere, but in this one case, compliance with ANSI C is more important, and
@@ -1466,17 +1476,27 @@ InternalPrintLibSPrintMarker (
Flags &= ~((UINTN) PREFIX_ZERO);
Precision = 1;
}
- if (Value < 0) {
+ if (Value < 0 && (Flags & UNSIGNED_TYPE) == 0) {
Flags |= PREFIX_SIGN;
Prefix = '-';
Value = -Value;
+ } else if ((Flags & UNSIGNED_TYPE) != 0 && (Flags & LONG_TYPE) == 0) {
+ //
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // This assumption is made so the format string definition is compatible with the ANSI C
+ // Specification for formatted strings. It is recommended that the Base Types be used
+ // everywhere, but in this one case, compliance with ANSI C is more important, and
+ // provides an implementation that is compatible with that largest possible set of CPU
+ // architectures. This is why the type "unsigned int" is used in this one case.
+ //
+ Value = (unsigned int)Value;
}
} else {
Radix = 16;
Comma = FALSE;
if ((Flags & LONG_TYPE) == 0 && Value < 0) {
//
- // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
// This assumption is made so the format string definition is compatible with the ANSI C
// Specification for formatted strings. It is recommended that the Base Types be used
// everywhere, but in this one case, compliance with ANSI C is more important, and
diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
index ce2f72aef8..68c1a5570b 100644
--- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
+++ b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
@@ -182,7 +182,7 @@ DebugPrint (
if ((*Format == 'p') && (sizeof (VOID *) > 4)) {
Long = TRUE;
}
- if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd') {
+ if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {
if (Long) {
BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
} else {