From nobody Sat Nov 2 16:33:30 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1486620183143342.7848491808073; Wed, 8 Feb 2017 22:03:03 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4F636820B0; Wed, 8 Feb 2017 22:03:00 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C5A5981FB0 for ; Wed, 8 Feb 2017 22:02:58 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 08 Feb 2017 22:02:58 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by orsmga001.jf.intel.com with ESMTP; 08 Feb 2017 22:02:57 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,349,1484035200"; d="scan'208";a="1092615589" From: Hao Wu To: edk2-devel@lists.01.org Date: Thu, 9 Feb 2017 14:02:49 +0800 Message-Id: <1486620170-38136-4-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1486620170-38136-1-git-send-email-hao.a.wu@intel.com> References: <1486620170-38136-1-git-send-email-hao.a.wu@intel.com> Subject: [edk2] [PATCH v2 3/4] MdeModulePkg/PrintLib: Use EFI_PRINT2S_PROTOCOL for this instance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Michael Kinney , Jiewen Yao , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The commit updates the PrintLib instance MdeModulePkg/Library/DxePrintLibPrint2Protocol to use EFI_PRINT2S_PROTOCOL to implement the APIs. Cc: Jiewen Yao Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.i= nf | 4 +- MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.u= ni | 10 ++-- MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c = | 56 +++++++++++++++----- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrin= t2Protocol.inf b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLib= Print2Protocol.inf index 55ee940..1cda2dc 100644 --- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Proto= col.inf +++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Proto= col.inf @@ -36,11 +36,11 @@ PcdLib =20 [Protocols] - gEfiPrint2ProtocolGuid ## CONSUMES + gEfiPrint2SProtocolGuid ## CONSUMES =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## SOMETIMES_CO= NSUMES gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## SOMETIMES_CO= NSUMES =20 [Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DX= E_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER] - gEfiPrint2ProtocolGuid + gEfiPrint2SProtocolGuid diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrin= t2Protocol.uni b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLib= Print2Protocol.uni index 29aa37c..3a9fb58 100644 --- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Proto= col.uni +++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Proto= col.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.
+// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
// // This program and the accompanying materials // are licensed and made available under the terms and conditions of the B= SD License @@ -15,7 +15,7 @@ // **/ =20 =20 -#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" =20 -#string STR_MODULE_DESCRIPTION #language en-US "Library instance = that implements Print Library class based on protocol gEfiPrint2ProtocolGui= d." +#string STR_MODULE_DESCRIPTION #language en-US "Library instance = that implements Print Library class based on protocol gEfiPrint2SProtocolGu= id." =20 diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c b/Md= eModulePkg/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. =20 Implement the print library instance by wrap the interface=20 - provided in the Print2 protocol. This protocol is defined as the internal + provided in the Print2S protocol. This protocol is defined as the intern= al protocol related to this implementation, not in the public spec. So, thi= s=20 library instance is only for this code base. =20 @@ -43,12 +43,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. } \ } while (FALSE) =20 -EFI_PRINT2_PROTOCOL *mPrint2Protocol =3D NULL; +EFI_PRINT2S_PROTOCOL *mPrint2SProtocol =3D NULL; =20 /** - The constructor function caches the pointer to Print2 protocol. + The constructor function caches the pointer to Print2S protocol. =20 - 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_S= UCCESS.=20 =20 @param ImageHandle The firmware allocated handle for the EFI image. @@ -67,12 +67,12 @@ PrintLibConstructor ( EFI_STATUS Status; =20 Status =3D SystemTable->BootServices->LocateProtocol ( - &gEfiPrint2ProtocolGuid, + &gEfiPrint2SProtocolGuid, NULL, - (VOID**) &mPrint2Protocol + (VOID**) &mPrint2SProtocol ); ASSERT_EFI_ERROR (Status); - ASSERT (mPrint2Protocol !=3D NULL); + ASSERT (mPrint2SProtocol !=3D NULL); =20 return Status; } @@ -362,7 +362,7 @@ UnicodeBSPrint ( { ASSERT_UNICODE_BUFFER (StartOfBuffer); ASSERT_UNICODE_BUFFER (FormatString); - return mPrint2Protocol->UnicodeBSPrint (StartOfBuffer, BufferSize, Forma= tString, Marker); + return mPrint2SProtocol->UnicodeBSPrint (StartOfBuffer, BufferSize, Form= atString, Marker); } =20 /** @@ -537,7 +537,7 @@ UnicodeBSPrintAsciiFormat ( ) { ASSERT_UNICODE_BUFFER (StartOfBuffer); - return mPrint2Protocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, Buffer= Size, FormatString, Marker); + return mPrint2SProtocol->UnicodeBSPrintAsciiFormat (StartOfBuffer, Buffe= rSize, FormatString, Marker); } =20 /** @@ -648,7 +648,21 @@ UnicodeValueToString ( IN UINTN Width ) { - return mPrint2Protocol->UnicodeValueToString (Buffer, Flags, Value, Widt= h); + RETURN_STATUS Status; + UINTN BufferSize; + + if (Width =3D=3D 0) { + BufferSize =3D (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR16); + } else { + BufferSize =3D (Width + 1) * sizeof (CHAR16); + } + + Status =3D mPrint2SProtocol->UnicodeValueToStringS (Buffer, BufferSize, = Flags, Value, Width); + if (RETURN_ERROR (Status)) { + return 0; + } + + return StrnLenS (Buffer, BufferSize / sizeof (CHAR16)); } =20 /** @@ -758,7 +772,7 @@ AsciiBSPrint ( IN BASE_LIST Marker ) { - return mPrint2Protocol->AsciiBSPrint (StartOfBuffer, BufferSize, FormatS= tring, Marker); + return mPrint2SProtocol->AsciiBSPrint (StartOfBuffer, BufferSize, Format= String, Marker); } =20 /** @@ -931,7 +945,7 @@ AsciiBSPrintUnicodeFormat ( ) { ASSERT_UNICODE_BUFFER (FormatString); - return mPrint2Protocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, Buffer= Size, FormatString, Marker); + return mPrint2SProtocol->AsciiBSPrintUnicodeFormat (StartOfBuffer, Buffe= rSize, FormatString, Marker); } =20 /** @@ -1042,7 +1056,21 @@ AsciiValueToString ( IN UINTN Width ) { - return mPrint2Protocol->AsciiValueToString (Buffer, Flags, Value, Width); + RETURN_STATUS Status; + UINTN BufferSize; + + if (Width =3D=3D 0) { + BufferSize =3D (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR8); + } else { + BufferSize =3D (Width + 1) * sizeof (CHAR8); + } + + Status =3D mPrint2SProtocol->AsciiValueToStringS (Buffer, BufferSize, Fl= ags, Value, Width); + if (RETURN_ERROR (Status)) { + return 0; + } + + return AsciiStrnLenS (Buffer, BufferSize / sizeof (CHAR8)); } =20 #define PREFIX_SIGN BIT1 --=20 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel