From: Hao Wu <hao.a.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Hao Wu <hao.a.wu@intel.com>, Jiewen Yao <jiewen.yao@intel.com>,
Liming Gao <liming.gao@intel.com>,
Michael Kinney <michael.d.kinney@intel.com>
Subject: [PATCH v2 3/4] MdeModulePkg/PrintLib: Use EFI_PRINT2S_PROTOCOL for this instance
Date: Thu, 9 Feb 2017 14:02:49 +0800 [thread overview]
Message-ID: <1486620170-38136-4-git-send-email-hao.a.wu@intel.com> (raw)
In-Reply-To: <1486620170-38136-1-git-send-email-hao.a.wu@intel.com>
The commit updates the PrintLib instance
MdeModulePkg/Library/DxePrintLibPrint2Protocol to use EFI_PRINT2S_PROTOCOL
to implement the APIs.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf | 4 +-
MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.uni | 10 ++--
MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c | 56 +++++++++++++++-----
3 files changed, 49 insertions(+), 21 deletions(-)
diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
index 55ee940..1cda2dc 100644
--- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
+++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
@@ -36,11 +36,11 @@
PcdLib
[Protocols]
- gEfiPrint2ProtocolGuid ## CONSUMES
+ gEfiPrint2SProtocolGuid ## CONSUMES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## SOMETIMES_CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## SOMETIMES_CONSUMES
[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]
- gEfiPrint2ProtocolGuid
+ gEfiPrint2SProtocolGuid
diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.uni b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.uni
index 29aa37c..3a9fb58 100644
--- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.uni
+++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.uni
@@ -1,9 +1,9 @@
// /** @file
-// Library instance that implements Print Library class based on protocol gEfiPrint2ProtocolGuid.
+// Library instance that implements Print Library class based on protocol gEfiPrint2SProtocolGuid.
//
-// Library instance that implements Print Library class based on protocol gEfiPrint2ProtocolGuid.
+// Library instance that implements Print Library class based on protocol gEfiPrint2SProtocolGuid.
//
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -15,7 +15,7 @@
// **/
-#string STR_MODULE_ABSTRACT #language en-US "Implements Print Library class based on protocol gEfiPrint2ProtocolGuid"
+#string STR_MODULE_ABSTRACT #language en-US "Implements Print Library class based on protocol gEfiPrint2SProtocolGuid"
-#string STR_MODULE_DESCRIPTION #language en-US "Library instance that implements Print Library class based on protocol gEfiPrint2ProtocolGuid."
+#string STR_MODULE_DESCRIPTION #language en-US "Library instance that implements Print Library class based on protocol gEfiPrint2SProtocolGuid."
diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
index 438ac9e..b3e7cb2 100644
--- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
+++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
@@ -1,8 +1,8 @@
/** @file
- Instance of Print Library based on gEfiPrint2ProtocolGuid.
+ Instance of Print Library based on gEfiPrint2SProtocolGuid.
Implement the print library instance by wrap the interface
- provided in the Print2 protocol. This protocol is defined as the internal
+ provided in the Print2S protocol. This protocol is defined as the internal
protocol related to this implementation, not in the public spec. So, this
library instance is only for this code base.
@@ -43,12 +43,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
} \
} while (FALSE)
-EFI_PRINT2_PROTOCOL *mPrint2Protocol = NULL;
+EFI_PRINT2S_PROTOCOL *mPrint2SProtocol = NULL;
/**
- The constructor function caches the pointer to Print2 protocol.
+ The constructor function caches the pointer to Print2S protocol.
- The constructor function locates Print2 protocol from protocol database.
+ The constructor function locates Print2S protocol from protocol database.
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@@ -67,12 +67,12 @@ PrintLibConstructor (
EFI_STATUS Status;
Status = SystemTable->BootServices->LocateProtocol (
- &gEfiPrint2ProtocolGuid,
+ &gEfiPrint2SProtocolGuid,
NULL,
- (VOID**) &mPrint2Protocol
+ (VOID**) &mPrint2SProtocol
);
ASSERT_EFI_ERROR (Status);
- ASSERT (mPrint2Protocol != NULL);
+ ASSERT (mPrint2SProtocol != NULL);
return Status;
}
@@ -362,7 +362,7 @@ UnicodeBSPrint (
{
ASSERT_UNICODE_BUFFER (StartOfBuffer);
ASSERT_UNICODE_BUFFER (FormatString);
- return mPrint2Protocol->UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+ return mPrint2SProtocol->UnicodeBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
}
/**
@@ -537,7 +537,7 @@ UnicodeBSPrintAsciiFormat (
)
{
ASSERT_UNICODE_BUFFER (StartOfBuffer);
- return mPrint2Protocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
+ return mPrint2SProtocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
}
/**
@@ -648,7 +648,21 @@ UnicodeValueToString (
IN UINTN Width
)
{
- return mPrint2Protocol->UnicodeValueToString (Buffer, Flags, Value, Width);
+ RETURN_STATUS Status;
+ UINTN BufferSize;
+
+ if (Width == 0) {
+ BufferSize = (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR16);
+ } else {
+ BufferSize = (Width + 1) * sizeof (CHAR16);
+ }
+
+ Status = mPrint2SProtocol->UnicodeValueToStringS (Buffer, BufferSize, Flags, Value, Width);
+ if (RETURN_ERROR (Status)) {
+ return 0;
+ }
+
+ return StrnLenS (Buffer, BufferSize / sizeof (CHAR16));
}
/**
@@ -758,7 +772,7 @@ AsciiBSPrint (
IN BASE_LIST Marker
)
{
- return mPrint2Protocol->AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+ return mPrint2SProtocol->AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
}
/**
@@ -931,7 +945,7 @@ AsciiBSPrintUnicodeFormat (
)
{
ASSERT_UNICODE_BUFFER (FormatString);
- return mPrint2Protocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);
+ return mPrint2SProtocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);
}
/**
@@ -1042,7 +1056,21 @@ AsciiValueToString (
IN UINTN Width
)
{
- return mPrint2Protocol->AsciiValueToString (Buffer, Flags, Value, Width);
+ RETURN_STATUS Status;
+ UINTN BufferSize;
+
+ if (Width == 0) {
+ BufferSize = (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR8);
+ } else {
+ BufferSize = (Width + 1) * sizeof (CHAR8);
+ }
+
+ Status = mPrint2SProtocol->AsciiValueToStringS (Buffer, BufferSize, Flags, Value, Width);
+ if (RETURN_ERROR (Status)) {
+ return 0;
+ }
+
+ return AsciiStrnLenS (Buffer, BufferSize / sizeof (CHAR8));
}
#define PREFIX_SIGN BIT1
--
1.9.5.msysgit.0
next prev parent reply other threads:[~2017-02-09 6:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-09 6:02 [PATCH v2 0/4] PrintLib: Add safe print functions [A|U]ValueToStringS Hao Wu
2017-02-09 6:02 ` [PATCH v2 1/4] MdePkg/BasePrintLib: " Hao Wu
2017-02-09 6:02 ` [PATCH v2 2/4] MdeModulePkg: Add the EFI_PRINT2S_PROTOCOL Hao Wu
2017-02-09 6:02 ` Hao Wu [this message]
2017-02-09 6:02 ` [PATCH v2 4/4] MdeModulePkg/PrintLib: Add safe print functions [A|U]ValueToStringS Hao Wu
2017-02-20 2:53 ` [PATCH v2 0/4] PrintLib: " Gao, Liming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486620170-38136-4-git-send-email-hao.a.wu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox