From nobody Sat May 4 16:25:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40073+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40073+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557208518; cv=none; d=zoho.com; s=zohoarc; b=gXDuI9sd03FAec9YDzIxrwAN+9bTsTW9YNVsAmrBWeAHVkZw+BTGhLzBgY3XGgctW1bgRau9vblVSvqOOxEoQQjluDexov4kdE3sBQrS9VYtm5EMaKpVpOD+EzgZ5HsrnOQtFIxqenpoYwqpRdjaAhhsp79p5q5UWnmN6SZLMd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557208518; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=uFAuw21XXTgfDskQLooPbWhbPwcRz85WkklWSvwdsSA=; b=KuGoOD3zWVqw5otyCJYA2VPYTHttfEz2vXh6j4101rUIiX8T9QLijytiGlhQ6mfOIcL35seboghuG/PSZu78arp+0KdcHezu4atc96Qv+BDLvDbse/8AYjrm9hqHnSqFj5mM+i+bt17rKvNDRcGivXXEWPy8vj3cnwlf0RjFU14= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40073+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557208518363892.9411047657995; Mon, 6 May 2019 22:55:18 -0700 (PDT) Return-Path: X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Mon, 06 May 2019 22:55:17 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 May 2019 22:55:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,440,1549958400"; d="scan'208";a="322336515" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga005.jf.intel.com with ESMTP; 06 May 2019 22:55:15 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Jian J Wang , Hao Wu , Ray Ni , Star Zeng , Eric Dong Subject: [edk2-devel] [PATCH v3] MdeModulePkg/DumpDynPcd: Add application to dump dynamic PCD settings Date: Tue, 7 May 2019 13:55:05 +0800 Message-Id: <20190507055505.3880-1-shenglei.zhang@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,shenglei.zhang@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557208517; bh=N1m/8JkxR4ltYfcDV8SLZY7ogX21A3VamsVevYyf7ks=; h=Cc:Date:From:Reply-To:Subject:To; b=FlnmX0sWAEk4DjlIrBzRtw0SHmFFyQXrnYfa9JuQCjQ4D9cskWsDY+LKHmiqL4Ug/Hh Dm2lqbaKjaO+NUEmSXt7802mUMYEqEoS5MN/TYJBdgBCZiVjg6TIw1bAxzPxg3196YX3y iClhJCxvmzKVrhEfDv8dU4ndBydSrBsSr3A= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is a shell application to dump dynamic PCD settings. Type DumpDynPcd -?/h/H to get help information. Type DumpDynPcd -v/V to get version information. Type DumpDynPcd [PcdName] to get Pcd information. https://bugzilla.tianocore.org/show_bug.cgi?id=3D1541 v2:1.Add static for global variables. 2.Change the parameter amount of InternalStrnCatGrow in DumpDynPcd.c. 3.Add open brace according to EDK II C Coding Standards Specification. 4.Remove the dependency on ShellPkg.dec in DumpDynPcd.inf. v3:Add static for all global variables and internal functions. Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng Cc: Eric Dong Signed-off-by: Shenglei Zhang Reviewed-by: Hao Wu --- .../Application/DumpDynPcd/DumpDynPcd.c | 612 ++++++++++++++++++ .../Application/DumpDynPcd/DumpDynPcd.inf | 50 ++ .../Application/DumpDynPcd/DumpDynPcdStr.uni | 28 + MdeModulePkg/MdeModulePkg.dsc | 1 + 4 files changed, 691 insertions(+) create mode 100644 MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.c create mode 100644 MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf create mode 100644 MdeModulePkg/Application/DumpDynPcd/DumpDynPcdStr.uni diff --git a/MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.c b/MdeModulePk= g/Application/DumpDynPcd/DumpDynPcd.c new file mode 100644 index 0000000000..025300ae3f --- /dev/null +++ b/MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.c @@ -0,0 +1,612 @@ +/** @file + A shell application to dump dynamic PCD settings. + + Copyright (c) 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + + +// +// String token ID of help message text. +// Shell supports to find help message in the resource section of an appli= cation image if +// .MAN file is not found. This global variable is added to make build too= l recognizes +// that the help string is consumed by user and then build tool will add t= he string into +// the resource section. Thus the application can use '-?' option to show = help message in +// Shell. +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStrDumpDynPcdHelpTokenId =3D = STRING_TOKEN (STR_DUMP_DYN_PCD_HELP_INFORMATION); + +#define MAJOR_VERSION 1 +#define MINOR_VERSION 0 + +static EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation =3D NULL; +static EFI_PCD_PROTOCOL *mPiPcd =3D NULL; +static PCD_PROTOCOL *mPcd =3D NULL; +static EFI_GET_PCD_INFO_PROTOCOL *mPiPcdInfo =3D NULL; +static GET_PCD_INFO_PROTOCOL *mPcdInfo =3D NULL; +static CHAR16 *mTempPcdNameBuffer =3D NULL; +static UINTN mTempPcdNameBufferSize =3D 0; + +static CONST CHAR8 mHex[] =3D {'0', '1', '2', '3', '4', '5', '6', '7', '8'= , '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + +static UINTN Argc; +static CHAR16 **Argv; + + +/** + + This function parse application ARG. + + @return Status +**/ +static +EFI_STATUS +GetArg ( + VOID + ) +{ + EFI_STATUS Status; + EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters; + + Status =3D gBS->HandleProtocol ( + gImageHandle, + &gEfiShellParametersProtocolGuid, + (VOID**)&ShellParameters + ); + if (EFI_ERROR(Status)) { + return Status; + } + + Argc =3D ShellParameters->Argc; + Argv =3D ShellParameters->Argv; + return EFI_SUCCESS; +} + +/** + Display current version. +**/ +static +VOID +ShowVersion ( + ) +{ + Print (L"DumpDynPcd Version %d.%02d\n", MAJOR_VERSION, MINOR_VERSION); +} + +/** + Display Usage and Help information. +**/ +static +VOID +ShowHelp ( + ) +{ + Print (L"Dump dynamic[ex] PCD info.\n"); + Print (L"\n"); + Print (L"DumpDynPcd [PcdName]\n"); + Print (L"\n"); + Print (L" PcdName Specifies the name of PCD.\n"); + Print (L" A literal[or partial] name or a pattern as specifi= ed in\n"); + Print (L" the MetaiMatch() function of the EFI_UNICODE_COLLA= TION2_PROCOOL.\n"); + Print (L" If it is absent, dump all PCDs' info.\n"); + Print (L"The PCD data is printed as hexadecimal dump.\n"); +} + +/** + Dump some hexadecimal data to the screen. + + @param[in] Indent How many spaces to indent the output. + @param[in] Offset The offset of the printing. + @param[in] DataSize The size in bytes of UserData. + @param[in] UserData The data to print out. +**/ +static +VOID +DumpHex ( + IN UINTN Indent, + IN UINTN Offset, + IN UINTN DataSize, + IN VOID *UserData + ) +{ + UINT8 *Data; + + CHAR8 Val[50]; + + CHAR8 Str[20]; + + UINT8 TempByte; + UINTN Size; + UINTN Index; + + Data =3D UserData; + while (DataSize !=3D 0) { + Size =3D 16; + if (Size > DataSize) { + Size =3D DataSize; + } + + for (Index =3D 0; Index < Size; Index +=3D 1) { + TempByte =3D Data[Index]; + Val[Index * 3 + 0] =3D mHex[TempByte >> 4]; + Val[Index * 3 + 1] =3D mHex[TempByte & 0xF]; + Val[Index * 3 + 2] =3D (CHAR8) ((Index =3D=3D 7) ? '-' : ' '); + Str[Index] =3D (CHAR8) ((TempByte < ' ' || TempByte > 'z') = ? '.' : TempByte); + } + + Val[Index * 3] =3D 0; + Str[Index] =3D 0; + Print (L"%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str); + + Data +=3D Size; + Offset +=3D Size; + DataSize -=3D Size; + } +} + + +/** + Safely append with automatic string resizing given length of Destination= and + desired length of copy from Source. + + append the first D characters of Source to the end of Destination, where= D is + the lesser of Count and the StrLen() of Source. If appending those D cha= racters + will fit within Destination (whose Size is given as CurrentSize) and + still leave room for a NULL terminator, then those characters are append= ed, + starting at the original terminating NULL of Destination, and a new term= inating + NULL is appended. + + If appending D characters onto Destination will result in a overflow of = the size + given in CurrentSize the string will be grown such that the copy can be = performed + and CurrentSize will be updated to the new size. + + If Source is NULL, there is nothing to append, just return the current b= uffer in + Destination. + + if Destination is NULL, then ASSERT() + if Destination's current length (including NULL terminator) is already m= ore then + CurrentSize, then ASSERT() + + @param[in, out] Destination The String to append onto + @param[in, out] CurrentSize on call the number of bytes in Destination= . On + return possibly the new size (still in byt= es). if NULL + then allocate whatever is needed. + @param[in] Source The String to append from + @param[in] Count Maximum number of characters to append. i= f 0 then + all are appended. + + @return Destination return the resultant string. +**/ +static +CHAR16* +InternalStrnCatGrow ( + IN OUT CHAR16 **Destination, + IN OUT UINTN *CurrentSize, + IN CONST CHAR16 *Source + ) +{ + UINTN DestinationStartSize; + UINTN NewSize; + UINTN SourceLen; + + SourceLen =3D StrLen(Source); + + // + // ASSERTs + // + ASSERT(Destination !=3D NULL); + + // + // If there's nothing to do then just return Destination + // + if (Source =3D=3D NULL) { + return (*Destination); + } + + // + // allow for un-initialized pointers, based on size being 0 + // + if (CurrentSize !=3D NULL && *CurrentSize =3D=3D 0) { + *Destination =3D NULL; + } + + // + // allow for NULL pointers address as Destination + // + if (*Destination !=3D NULL) { + ASSERT(CurrentSize !=3D 0); + DestinationStartSize =3D StrSize(*Destination); + ASSERT(DestinationStartSize <=3D *CurrentSize); + } else { + DestinationStartSize =3D 0; + } + + // + // Test and grow if required + // + if (CurrentSize !=3D NULL) { + NewSize =3D *CurrentSize; + if (NewSize < DestinationStartSize + (SourceLen * sizeof(CHAR16))) { + while (NewSize < (DestinationStartSize + (SourceLen*sizeof(CHAR16)))= ) { + NewSize +=3D 2 * SourceLen * sizeof(CHAR16); + } + *Destination =3D ReallocatePool(*CurrentSize, NewSize, *Destination); + *CurrentSize =3D NewSize; + } + } else { + NewSize =3D (SourceLen + 1)*sizeof(CHAR16); + *Destination =3D AllocateZeroPool(NewSize); + } + + // + // Now use standard StrnCat on a big enough buffer + // + if (*Destination =3D=3D NULL) { + return (NULL); + } + + StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, SourceLen); + return *Destination; +} + +/** + Get PCD type string based on input PCD type. + + @param[in] TokenSpace PCD Token Space. + @param[in] PcdType The input PCD type. + + @return Pointer to PCD type string. +**/ +static +CHAR16 * +GetPcdTypeString ( + IN CONST EFI_GUID *TokenSpace, + IN EFI_PCD_TYPE PcdType + ) +{ + UINTN BufLen; + CHAR16 *RetString; + + BufLen =3D 0; + RetString =3D NULL; + + switch (PcdType) { + case EFI_PCD_TYPE_8: + InternalStrnCatGrow (&RetString, &BufLen, L"UINT8"); + break; + case EFI_PCD_TYPE_16: + InternalStrnCatGrow (&RetString, &BufLen, L"UINT16"); + break; + case EFI_PCD_TYPE_32: + InternalStrnCatGrow (&RetString, &BufLen, L"UINT32"); + break; + case EFI_PCD_TYPE_64: + InternalStrnCatGrow (&RetString, &BufLen, L"UINT64"); + break; + case EFI_PCD_TYPE_BOOL: + InternalStrnCatGrow (&RetString, &BufLen, L"BOOLEAN"); + break; + case EFI_PCD_TYPE_PTR: + InternalStrnCatGrow (&RetString, &BufLen, L"POINTER"); + break; + default: + InternalStrnCatGrow (&RetString, &BufLen, L"UNKNOWN"); + break; + } + + if (TokenSpace =3D=3D NULL) { + InternalStrnCatGrow (&RetString, &BufLen, L":DYNAMIC"); + } else { + InternalStrnCatGrow (&RetString, &BufLen, L":DYNAMICEX"); + } + + return RetString; +} + +/** + Dump PCD info. + + @param[in] TokenSpace PCD Token Space. + @param[in] TokenNumber PCD Token Number. + @param[in] PcdInfo Pointer to PCD info. +**/ +static +VOID +DumpPcdInfo ( + IN CONST EFI_GUID *TokenSpace, + IN UINTN TokenNumber, + IN EFI_PCD_INFO *PcdInfo + ) +{ + CHAR16 *RetString; + UINT8 Uint8; + UINT16 Uint16; + UINT32 Uint32; + UINT64 Uint64; + BOOLEAN Boolean; + VOID *PcdData; + + RetString =3D NULL; + + if (PcdInfo->PcdName !=3D NULL) { + Print (L"%a\n", PcdInfo->PcdName); + } else { + if (TokenSpace =3D=3D NULL) { + Print (L"Default Token Space\n"); + } else { + Print (L"%g\n", TokenSpace); + } + } + + RetString =3D GetPcdTypeString (TokenSpace, PcdInfo->PcdType); + + switch (PcdInfo->PcdType) { + case EFI_PCD_TYPE_8: + if (TokenSpace =3D=3D NULL) { + Uint8 =3D mPcd->Get8 (TokenNumber); + } else { + Uint8 =3D mPiPcd->Get8 (TokenSpace, TokenNumber); + } + Print (L" Token =3D 0x%08x - Type =3D %H%-17s%N - Size =3D 0x%x - V= alue =3D 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint8); + break; + case EFI_PCD_TYPE_16: + if (TokenSpace =3D=3D NULL) { + Uint16 =3D mPcd->Get16 (TokenNumber); + } else { + Uint16 =3D mPiPcd->Get16 (TokenSpace, TokenNumber); + } + Print (L" Token =3D 0x%08x - Type =3D %H%-17s%N - Size =3D 0x%x - V= alue =3D 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint16); + break; + case EFI_PCD_TYPE_32: + if (TokenSpace =3D=3D NULL) { + Uint32 =3D mPcd->Get32 (TokenNumber); + } else { + Uint32 =3D mPiPcd->Get32 (TokenSpace, TokenNumber); + } + Print (L" Token =3D 0x%08x - Type =3D %H%-17s%N - Size =3D 0x%x - V= alue =3D 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint32); + break; + case EFI_PCD_TYPE_64: + if (TokenSpace =3D=3D NULL) { + Uint64 =3D mPcd->Get64 (TokenNumber); + } else { + Uint64 =3D mPiPcd->Get64 (TokenSpace, TokenNumber); + } + Print (L" Token =3D 0x%08x - Type =3D %H%-17s%N - Size =3D 0x%x - V= alue =3D 0x%lx\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint64); + break; + case EFI_PCD_TYPE_BOOL: + if (TokenSpace =3D=3D NULL) { + Boolean =3D mPcd->GetBool (TokenNumber); + } else { + Boolean =3D mPiPcd->GetBool (TokenSpace, TokenNumber); + } + Print (L" Token =3D 0x%08x - Type =3D %H%-17s%N - Size =3D 0x%x - V= alue =3D %a\n", TokenNumber, RetString, PcdInfo->PcdSize, Boolean ? "TRUE" = : "FALSE"); + break; + case EFI_PCD_TYPE_PTR: + if (TokenSpace =3D=3D NULL) { + PcdData =3D mPcd->GetPtr (TokenNumber); + } else { + PcdData =3D mPiPcd->GetPtr (TokenSpace, TokenNumber); + } + Print (L" Token =3D 0x%08x - Type =3D %H%-17s%N - Size =3D 0x%x\n",= TokenNumber, RetString, PcdInfo->PcdSize); + DumpHex (2, 0, PcdInfo->PcdSize, PcdData); + break; + default: + return; + } + + if (RetString !=3D NULL) { + FreePool (RetString); + } + Print (L"\n"); +} + +/** + Show one or all PCDs' info. + + @param[in] InputPcdName Pointer to PCD name to show. If NULL, sho= w all PCDs' info. + + @retval EFI_SUCCESS Command completed successfully. + @retval EFI_OUT_OF_RESOURCES Not enough resources were available to ru= n the command. + @retval EFI_ABORTED Aborted by user. + @retval EFI_NOT_FOUND The specified PCD is not found. +**/ +static +EFI_STATUS +ProcessPcd ( + IN CHAR16 *InputPcdName + ) +{ + EFI_STATUS Status; + EFI_GUID *TokenSpace; + UINTN TokenNumber; + EFI_PCD_INFO PcdInfo; + BOOLEAN Found; + UINTN PcdNameSize; + + PcdInfo.PcdName =3D NULL; + PcdInfo.PcdSize =3D 0; + PcdInfo.PcdType =3D 0xFF; + Found =3D FALSE; + + Print (L"Current system SKU ID: 0x%x\n\n", mPiPcdInfo->GetSku ()); + + TokenSpace =3D NULL; + do { + TokenNumber =3D 0; + do { + Status =3D mPiPcd->GetNextToken (TokenSpace, &TokenNumber); + if (!EFI_ERROR (Status) && TokenNumber !=3D 0) { + if (TokenSpace =3D=3D NULL) { + // + // PCD in default Token Space. + // + mPcdInfo->GetInfo (TokenNumber, &PcdInfo); + } else { + mPiPcdInfo->GetInfo (TokenSpace, TokenNumber, &PcdInfo); + } + if (InputPcdName !=3D NULL) { + if (PcdInfo.PcdName =3D=3D NULL) { + continue; + } + PcdNameSize =3D AsciiStrSize (PcdInfo.PcdName) * sizeof (CHAR16); + if (mTempPcdNameBuffer =3D=3D NULL) { + mTempPcdNameBufferSize =3D PcdNameSize; + mTempPcdNameBuffer =3D AllocatePool (mTempPcdNameBufferSize); + } else if (mTempPcdNameBufferSize < PcdNameSize) { + mTempPcdNameBuffer =3D ReallocatePool (mTempPcdNameBufferSize,= PcdNameSize, mTempPcdNameBuffer); + mTempPcdNameBufferSize =3D PcdNameSize; + } + if (mTempPcdNameBuffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + AsciiStrToUnicodeStrS (PcdInfo.PcdName, mTempPcdNameBuffer, mTem= pPcdNameBufferSize / sizeof (CHAR16)); + // + // Compare the input PCD name with the PCD name in PCD database. + // + if ((StrStr (mTempPcdNameBuffer, InputPcdName) !=3D NULL) || + (mUnicodeCollation !=3D NULL && mUnicodeCollation->MetaiMatc= h (mUnicodeCollation, mTempPcdNameBuffer, InputPcdName))) { + // + // Found matched PCD. + // + DumpPcdInfo (TokenSpace, TokenNumber, &PcdInfo); + Found =3D TRUE; + } + } else { + DumpPcdInfo (TokenSpace, TokenNumber, &PcdInfo); + } + } + } while (!EFI_ERROR (Status) && TokenNumber !=3D 0); + + Status =3D mPiPcd->GetNextTokenSpace ((CONST EFI_GUID **) &TokenSpace); + } while (!EFI_ERROR (Status) && TokenSpace !=3D NULL); + + if ((InputPcdName !=3D NULL) && !Found) { + // + // The specified PCD is not found, print error. + // + Print (L"%EError. %NNo matching PCD found: %s.\n", InputPcdName); + return EFI_NOT_FOUND; + } + return EFI_SUCCESS; +} + +/** + Main entrypoint for DumpDynPcd shell application. + + @param[in] ImageHandle The image handle. + @param[in] SystemTable The system table. + + @retval EFI_SUCCESS Command completed successfully. + @retval EFI_INVALID_PARAMETER Command usage error. + @retval EFI_OUT_OF_RESOURCES Not enough resources were available to ru= n the command. + @retval EFI_ABORTED Aborted by user. + @retval EFI_NOT_FOUND The specified PCD is not found. + @retval Others Error status returned from gBS->LocatePro= tocol. +**/ +EFI_STATUS +EFIAPI +DumpDynPcdMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + CHAR16 *InputPcdName; + + InputPcdName =3D NULL; + + Status =3D gBS->LocateProtocol(&gEfiUnicodeCollation2ProtocolGuid, NULL,= (VOID **) &mUnicodeCollation); + if (EFI_ERROR (Status)) { + mUnicodeCollation =3D NULL; + } + + Status =3D gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &m= PiPcd); + if (EFI_ERROR (Status)) { + Print (L"DumpDynPcd: %EError. %NPI PCD protocol is not present.\n"); + return Status; + } + + Status =3D gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID= **) &mPiPcdInfo); + if (EFI_ERROR (Status)) { + Print (L"DumpDynPcd: %EError. %NPI PCD info protocol is not present.\n= "); + return Status; + } + + Status =3D gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **) &mPcd= ); + if (EFI_ERROR (Status)) { + Print (L"DumpDynPcd: %EError. %NPCD protocol is not present.\n"); + return Status; + } + + Status =3D gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **= ) &mPcdInfo); + if (EFI_ERROR (Status)) { + Print (L"DumpDynPcd: %EError. %NPCD info protocol is not present.\n"); + return Status; + } + + // + // get the command line arguments + // + Status =3D GetArg(); + if (EFI_ERROR(Status)){ + Print (L"DumpDynPcd: %EError. %NThe input parameters are not recognize= d.\n"); + Status =3D EFI_INVALID_PARAMETER; + return Status; + } + + if (Argc > 2){ + Print (L"DumpDynPcd: %EError. %NToo many arguments specified.\n"); + Status =3D EFI_INVALID_PARAMETER; + return Status; + } + + if (Argc =3D=3D 1){ + Status =3D ProcessPcd (InputPcdName); + goto Done; + } + + if ((StrCmp(Argv[1], L"-?") =3D=3D 0)||(StrCmp(Argv[1], L"-h") =3D=3D 0)= ||(StrCmp(Argv[1], L"-H") =3D=3D 0)){ + ShowHelp (); + goto Done; + } else { + if ((StrCmp(Argv[1], L"-v") =3D=3D 0)||(StrCmp(Argv[1], L"-V") =3D=3D = 0)){ + ShowVersion (); + goto Done; + } else { + if (StrStr(Argv[1], L"-") !=3D NULL){ + Print (L"DumpDynPcd: %EError. %NThe argument '%B%s%N' is invalid.\= n", Argv[1]); + goto Done; + } + } + } + + InputPcdName =3D Argv[1]; + Status =3D ProcessPcd (InputPcdName); + + Done: + + if (mTempPcdNameBuffer !=3D NULL) { + FreePool (mTempPcdNameBuffer); + } + + return Status; +} + diff --git a/MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf b/MdeModule= Pkg/Application/DumpDynPcd/DumpDynPcd.inf new file mode 100644 index 0000000000..a3542dd367 --- /dev/null +++ b/MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf @@ -0,0 +1,50 @@ +## @file +# DumpDynPcd is a shell application to dump dynamic pcd information. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D DumpDynPcd + FILE_GUID =3D 31ADA2B2-62EA-4866-9B87-03FEA8425974 + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D DumpDynPcdMain + +# +# This flag specifies whether HII resource section is generated into PE im= age. +# + UEFI_HII_RESOURCE_SECTION =3D TRUE + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + DumpDynPcd.c + DumpDynPcdStr.uni + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + UefiApplicationEntryPoint + DebugLib + MemoryAllocationLib + UefiLib + UefiBootServicesTableLib + +[Protocols] + gEfiUnicodeCollation2ProtocolGuid ## SOMETIMES_CONSUMES + gEfiPcdProtocolGuid ## CONSUMES + gPcdProtocolGuid ## CONSUMES + gEfiGetPcdInfoProtocolGuid ## CONSUMES + gGetPcdInfoProtocolGuid ## CONSUMES + gEfiShellParametersProtocolGuid ## CONSUMES + diff --git a/MdeModulePkg/Application/DumpDynPcd/DumpDynPcdStr.uni b/MdeMod= ulePkg/Application/DumpDynPcd/DumpDynPcdStr.uni new file mode 100644 index 0000000000..f0ee98219b --- /dev/null +++ b/MdeModulePkg/Application/DumpDynPcd/DumpDynPcdStr.uni @@ -0,0 +1,28 @@ +// +// DumpDynPcd is a shell application to dump dynamic pcd information. +// +// Copyright (c) 2019, Intel Corporation. All rights reserved.
+// SPDX-License-Identifier: BSD-2-Clause-Patent +// +//**/ + +/=3D# + +#langdef en-US "English" + +#string STR_DUMP_DYN_PCD_HELP_INFORMATION #language en-US "" + ".TH DumpD= ynPcd 0 "Dump dynamic[ex] PCD info."\r\n" + ".SH NAME\= r\n" + "Dump dyna= mic[ex] PCD info.\r\n" + ".SH SYNOP= SIS\r\n" + " \r\n" + "DumpDynPc= d [PcdName].\r\n" + ".SH OPTIO= NS\r\n" + " \r\n" + " PcdName= Specifies the name of PCD.\r\n" + " = A literal[or partial] name or a pattern as specified in\r\n" + " = the MetaiMatch() function of the EFI_UNICODE_COLLATION2_PROCOOL.\r\n" + " = If it is absent, dump all PCDs' info.\r\n" + "The PCD d= ata is printed as hexadecimal dump.\n" + "\r\n" + diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b302f4a4f3..a8b9d8d027 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -206,6 +206,7 @@ =20 [Components] MdeModulePkg/Application/HelloWorld/HelloWorld.inf + MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.inf =20 MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#40073): https://edk2.groups.io/g/devel/message/40073 Mute This Topic: https://groups.io/mt/31529240/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-