summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BasePrintLib
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-30 23:45:50 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-30 23:45:50 +0000
commit2075236eefe532097caa04aa2606e2b7cda4e420 (patch)
treedc41df028a32c2b9133a1069b8e9c2e4db334aca /MdePkg/Library/BasePrintLib
parent37e97c51dd30f457b161a7fed8ddd6db0f90fc35 (diff)
downloadedk2-platforms-2075236eefe532097caa04aa2606e2b7cda4e420.tar.xz
This checkin addresses the compatibility issue of passing arguments of type VA_LIST between components. The type VA_LIST is mapped onto the compiler specific implementation of varargs. As a result, modules build with different compilers may not use the same VA_LIST structure. The solution to this issue is to define a new type called BASE_LIST that is a compiler independent method of passing varargs between modules.
Add BASE_LIST type to Base.h Add BAS_ARG() macro to Base.h Add 4 functions to PrintLib.h that use BASE_LIST. Change ReportStatsuCodeExtractDebugInfo() from ReportStatusCodeLib.h to take a BASE_LIST argument instead of a VA_LIST argument Add the 4 new functions to BasePrintLib implementation that use BASE_LIST Update BaseReportStatusCodeLib implementation of ReportStatsuCodeExtractDebugInfo() to use a BASE_LIST argument instead of a VA_LIST argument git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8404 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BasePrintLib')
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLib.c199
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.c129
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.h20
3 files changed, 286 insertions, 62 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c
index c50c4eae7d..2066c7a1dd 100644
--- a/MdePkg/Library/BasePrintLib/PrintLib.c
+++ b/MdePkg/Library/BasePrintLib/PrintLib.c
@@ -59,9 +59,57 @@ UnicodeVSPrint (
IN VA_LIST Marker
)
{
- ASSERT_UNICODE_BUFFER(StartOfBuffer);
- ASSERT_UNICODE_BUFFER(FormatString);
- return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);
+ ASSERT_UNICODE_BUFFER (StartOfBuffer);
+ ASSERT_UNICODE_BUFFER (FormatString);
+ return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);
+}
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on
+ a Null-terminated Unicode format string and a BASE_LIST argument list
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on the
+ contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker BASE_LIST marker for the variable argument list.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeBSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN BASE_LIST Marker
+ )
+{
+ ASSERT_UNICODE_BUFFER (StartOfBuffer);
+ ASSERT_UNICODE_BUFFER (FormatString);
+ return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, NULL, Marker);
}
/**
@@ -155,8 +203,54 @@ UnicodeVSPrintAsciiFormat (
IN VA_LIST Marker
)
{
- ASSERT_UNICODE_BUFFER(StartOfBuffer);
- return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);
+ ASSERT_UNICODE_BUFFER (StartOfBuffer);
+ return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, Marker, NULL);
+}
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ ASCII format string and a BASE_LIST argument list
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on the
+ contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated ASCII format string.
+ @param Marker BASE_LIST marker for the variable argument list.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeBSPrintAsciiFormat (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN BASE_LIST Marker
+ )
+{
+ ASSERT_UNICODE_BUFFER (StartOfBuffer);
+ return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, NULL, Marker);
}
/**
@@ -303,7 +397,51 @@ AsciiVSPrint (
IN VA_LIST Marker
)
{
- return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);
+ return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, Marker, NULL);
+}
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and a BASE_LIST argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on
+ the contents of the format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated ASCII format string.
+ @param Marker BASE_LIST marker for the variable argument list.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiBSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN BASE_LIST Marker
+ )
+{
+ return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, NULL, Marker);
}
/**
@@ -397,7 +535,53 @@ AsciiVSPrintUnicodeFormat (
)
{
ASSERT_UNICODE_BUFFER (FormatString);
- return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);
+ return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);
+}
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ Unicode format string and a BASE_LIST argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on
+ the contents of the format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker BASE_LIST marker for the variable argument list.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiBSPrintUnicodeFormat (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN BASE_LIST Marker
+ )
+{
+ ASSERT_UNICODE_BUFFER (FormatString);
+ return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, NULL, Marker);
}
/**
@@ -501,4 +685,3 @@ AsciiValueToString (
{
return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);
}
-
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
index 67d60fb255..ef006bbd00 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
@@ -275,52 +275,54 @@ BasePrintLibConvertValueToString (
VA_LIST is used this routine allows the nesting of Vararg routines. Thus
this is the main print working routine.
- @param Buffer Character buffer to print the results of the parsing
- of Format into.
- @param BufferSize Maximum number of characters to put into buffer.
- @param Flags Initial flags value.
- Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
- @param Format Null-terminated format string.
- @param Marker Vararg list consumed by processing Format.
+ @param Buffer Character buffer to print the results of the parsing
+ of Format into.
+ @param BufferSize Maximum number of characters to put into buffer.
+ @param Flags Initial flags value.
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
+ @param Format Null-terminated format string.
+ @param VaListMarker VA_LIST style variable argument list consumed by processing Format.
+ @param BaseListMarker BASE_LIST style variable argument list consumed by processing Format.
@return Number of characters printed not including the Null-terminator.
**/
UINTN
-BasePrintLibVSPrint (
+BasePrintLibSPrintMarker (
OUT CHAR8 *Buffer,
IN UINTN BufferSize,
IN UINTN Flags,
IN CONST CHAR8 *Format,
- IN VA_LIST Marker
+ IN VA_LIST VaListMarker, OPTIONAL
+ IN BASE_LIST BaseListMarker OPTIONAL
)
{
- CHAR8 *OriginalBuffer;
- CHAR8 *EndBuffer;
- CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];
- UINTN BytesPerOutputCharacter;
- UINTN BytesPerFormatCharacter;
- UINTN FormatMask;
- UINTN FormatCharacter;
- UINTN Width;
- UINTN Precision;
- INT64 Value;
- CONST CHAR8 *ArgumentString;
- UINTN Character;
- GUID *TmpGuid;
- TIME *TmpTime;
- UINTN Count;
- UINTN ArgumentMask;
- INTN BytesPerArgumentCharacter;
- UINTN ArgumentCharacter;
- BOOLEAN Done;
- UINTN Index;
- CHAR8 Prefix;
- BOOLEAN ZeroPad;
- BOOLEAN Comma;
- UINTN Digits;
- UINTN Radix;
- RETURN_STATUS Status;
+ CHAR8 *OriginalBuffer;
+ CHAR8 *EndBuffer;
+ CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];
+ UINTN BytesPerOutputCharacter;
+ UINTN BytesPerFormatCharacter;
+ UINTN FormatMask;
+ UINTN FormatCharacter;
+ UINTN Width;
+ UINTN Precision;
+ INT64 Value;
+ CONST CHAR8 *ArgumentString;
+ UINTN Character;
+ GUID *TmpGuid;
+ TIME *TmpTime;
+ UINTN Count;
+ UINTN ArgumentMask;
+ INTN BytesPerArgumentCharacter;
+ UINTN ArgumentCharacter;
+ BOOLEAN Done;
+ UINTN Index;
+ CHAR8 Prefix;
+ BOOLEAN ZeroPad;
+ BOOLEAN Comma;
+ UINTN Digits;
+ UINTN Radix;
+ RETURN_STATUS Status;
if (BufferSize == 0) {
return 0;
@@ -338,6 +340,7 @@ BasePrintLibVSPrint (
//
BufferSize--;
OriginalBuffer = Buffer;
+
//
// Set the tag for the end of the input Buffer.
//
@@ -417,9 +420,17 @@ BasePrintLibVSPrint (
case '*':
if ((Flags & PRECISION) == 0) {
Flags |= PAD_TO_WIDTH;
- Width = VA_ARG (Marker, UINTN);
+ if (BaseListMarker == NULL) {
+ Width = VA_ARG (VaListMarker, UINTN);
+ } else {
+ Width = BASE_ARG (BaseListMarker, UINTN);
+ }
} else {
- Precision = VA_ARG (Marker, UINTN);
+ if (BaseListMarker == NULL) {
+ Precision = VA_ARG (VaListMarker, UINTN);
+ } else {
+ Precision = BASE_ARG (BaseListMarker, UINTN);
+ }
}
break;
case '0':
@@ -497,9 +508,17 @@ BasePrintLibVSPrint (
// provides an implementation that is compatible with that largest possible set of CPU
// architectures. This is why the type "int" is used in this one case.
//
- Value = (VA_ARG (Marker, int));
+ if (BaseListMarker == NULL) {
+ Value = VA_ARG (VaListMarker, int);
+ } else {
+ Value = BASE_ARG (BaseListMarker, int);
+ }
} else {
- Value = VA_ARG (Marker, INT64);
+ if (BaseListMarker == NULL) {
+ Value = VA_ARG (VaListMarker, INT64);
+ } else {
+ Value = BASE_ARG (BaseListMarker, INT64);
+ }
}
if ((Flags & PREFIX_BLANK) != 0) {
Prefix = ' ';
@@ -576,7 +595,11 @@ BasePrintLibVSPrint (
// break skipped on purpose
//
case 'a':
- ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *);
+ if (BaseListMarker == NULL) {
+ ArgumentString = VA_ARG (VaListMarker, CHAR8 *);
+ } else {
+ ArgumentString = BASE_ARG (BaseListMarker, CHAR8 *);
+ }
if (ArgumentString == NULL) {
Flags &= (~ARGUMENT_UNICODE);
ArgumentString = "<null string>";
@@ -590,13 +613,21 @@ BasePrintLibVSPrint (
break;
case 'c':
- Character = VA_ARG (Marker, UINTN) & 0xffff;
+ if (BaseListMarker == NULL) {
+ Character = VA_ARG (VaListMarker, UINTN) & 0xffff;
+ } else {
+ Character = BASE_ARG (BaseListMarker, UINTN) & 0xffff;
+ }
ArgumentString = (CHAR8 *)&Character;
Flags |= ARGUMENT_UNICODE;
break;
case 'g':
- TmpGuid = VA_ARG (Marker, GUID *);
+ if (BaseListMarker == NULL) {
+ TmpGuid = VA_ARG (VaListMarker, GUID *);
+ } else {
+ TmpGuid = BASE_ARG (BaseListMarker, GUID *);
+ }
if (TmpGuid == NULL) {
ArgumentString = "<null guid>";
} else {
@@ -622,7 +653,11 @@ BasePrintLibVSPrint (
break;
case 't':
- TmpTime = VA_ARG (Marker, TIME *);
+ if (BaseListMarker == NULL) {
+ TmpTime = VA_ARG (VaListMarker, TIME *);
+ } else {
+ TmpTime = BASE_ARG (BaseListMarker, TIME *);
+ }
if (TmpTime == NULL) {
ArgumentString = "<null time>";
} else {
@@ -642,7 +677,11 @@ BasePrintLibVSPrint (
break;
case 'r':
- Status = VA_ARG (Marker, RETURN_STATUS);
+ if (BaseListMarker == NULL) {
+ Status = VA_ARG (VaListMarker, RETURN_STATUS);
+ } else {
+ Status = BASE_ARG (BaseListMarker, RETURN_STATUS);
+ }
ArgumentString = ValueBuffer;
if (RETURN_ERROR (Status)) {
//
@@ -833,5 +872,5 @@ BasePrintLibSPrint (
VA_LIST Marker;
VA_START (Marker, FormatString);
- return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);
+ return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, Flags, FormatString, Marker, NULL);
}
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
index 5369620e3e..b0c05940d7 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
@@ -59,24 +59,26 @@ typedef struct {
VA_LIST is used this routine allows the nesting of Vararg routines. Thus
this is the main print working routine.
- @param Buffer Character buffer to print the results of the parsing
- of Format into.
- @param BufferSize Maximum number of characters to put into buffer.
- @param Flags Initial flags value.
- Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
- @param Format Null-terminated format string.
- @param Marker Vararg list consumed by processing Format.
+ @param Buffer Character buffer to print the results of the parsing
+ of Format into.
+ @param BufferSize Maximum number of characters to put into buffer.
+ @param Flags Initial flags value.
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
+ @param Format Null-terminated format string.
+ @param VaListMarker VA_LIST style variable argument list consumed by processing Format.
+ @param BaseListMarker BASE_LIST style variable argument list consumed by processing Format.
@return Number of characters printed not including the Null-terminator.
**/
UINTN
-BasePrintLibVSPrint (
+BasePrintLibSPrintMarker (
OUT CHAR8 *Buffer,
IN UINTN BufferSize,
IN UINTN Flags,
IN CONST CHAR8 *Format,
- IN VA_LIST Marker
+ IN VA_LIST VaListMarker, OPTIONAL
+ IN BASE_LIST BaseListMarker OPTIONAL
);
/**