diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-23 07:07:07 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-23 07:07:07 +0000 |
commit | 0f77dfb62292f27e1bf07427ae4e885401a96352 (patch) | |
tree | 280937306c1567279828b9e1eb0702aedc16d13c /EdkCompatibilityPkg | |
parent | 34a0bac4750ad7b18d72e67fbfb670bb892796af (diff) | |
download | edk2-platforms-0f77dfb62292f27e1bf07427ae4e885401a96352.tar.xz |
Enhance the string formatting function to take "%p" to print pointer.
'p' - arugment is VOID *; printed as hex number
Example is :
ASPrint (Buffer, 1024, "This is a %p\n", SystemTable);
ASPrint (Buffer, 1024, "This is a %10p\n", SystemTable);
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5554 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg')
3 files changed, 64 insertions, 0 deletions
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c index 4e0980a1fc..2ed4eeca23 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c @@ -573,6 +573,27 @@ Returns: //
Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
switch (*Format) {
+ case 'p':
+ //
+ // Flag space, +, 0, L & l are invalid for type p.
+ //
+ Flags &= ~(PREFIX_BLANK| PREFIX_SIGN | LONG_TYPE);
+ if (sizeof (VOID *) > 4) {
+ Flags |= LONG_TYPE;
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = VA_ARG (Marker, UINTN);
+ }
+ Flags |= PREFIX_ZERO;
+
+ EfiValueToHexStr (TempBuffer, Value, Flags, Width);
+ UnicodeStr = TempBuffer;
+
+ for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ break;
+
case 'X':
Flags |= PREFIX_ZERO;
Width = sizeof (UINT64) * 2;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c index b4f9a740ce..f72cac41ca 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Print.c @@ -39,6 +39,7 @@ Abstract: Decimal number that represents width of print
type:
+ 'p' - arugment is VOID *; printed as hex number
'X' - argument is a UINTN hex number, prefix '0'
'x' - argument is a hex number
'd' - argument is a decimal number
@@ -206,6 +207,27 @@ Returns: //
Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
switch (*Format) {
+ case 'p':
+ //
+ // Flag space, +, 0, L & l are invalid for type p.
+ //
+ Flags &= ~(PREFIX_BLANK| PREFIX_SIGN | LONG_TYPE);
+ if (sizeof (VOID *) > 4) {
+ Flags |= LONG_TYPE;
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = VA_ARG (Marker, UINTN);
+ }
+ Flags |= PREFIX_ZERO;
+
+ EfiValueToHexStr (TempBuffer, Value, Flags, Width);
+ UnicodeStr = TempBuffer;
+
+ for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ break;
+
case 'X':
Flags |= PREFIX_ZERO;
Width = sizeof (UINT64) * 2;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c index 458bb9ce4a..c35b830b51 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Print/Print.c @@ -39,6 +39,7 @@ Abstract: Decimal number that represents width of print
type:
+ 'p' - arugment is VOID *; printed as hex number
'X' - argument is a UINTN hex number, prefix '0'
'x' - argument is a hex number
'd' - argument is a decimal number
@@ -220,6 +221,26 @@ Returns: //
Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
switch (*Format) {
+ case 'p':
+ //
+ // Flag space, +, 0, L & l are invalid for type p.
+ //
+ Flags &= ~(PREFIX_BLANK| PREFIX_SIGN | LONG_TYPE);
+ if (sizeof (VOID *) > 4) {
+ Flags |= LONG_TYPE;
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = VA_ARG (Marker, UINTN);
+ }
+ Flags |= PREFIX_ZERO;
+
+ ValueTomHexStr (TempBuffer, Value, Flags, Width);
+ AsciiStr = TempBuffer;
+
+ for (; (*AsciiStr != '\0') && (Index < BufferSize - 1); AsciiStr++) {
+ Buffer[Index++] = *AsciiStr;
+ }
+ break;
case 'X':
Flags |= PREFIX_ZERO;
Width = sizeof (UINT64) * 2;
|