From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 5A47681953 for ; Mon, 9 Jan 2017 01:31:10 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 09 Jan 2017 01:30:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="211175757" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 09 Jan 2017 01:30:57 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Chen A Chen Date: Mon, 9 Jan 2017 17:30:50 +0800 Message-Id: <20170109093052.140504-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20170109093052.140504-1-ruiyu.ni@intel.com> References: <20170109093052.140504-1-ruiyu.ni@intel.com> Subject: [PATCH 3/5] ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids 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: , X-List-Received-Date: Mon, 09 Jan 2017 09:31:11 -0000 From: Chen A Chen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Signed-off-by: Chen A Chen --- ShellPkg/Include/Library/HandleParsingLib.h | 21 ++++++++- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 52 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Include/Library/HandleParsingLib.h b/ShellPkg/Include/Library/HandleParsingLib.h index 79dcc9c..b02cf4f 100644 --- a/ShellPkg/Include/Library/HandleParsingLib.h +++ b/ShellPkg/Include/Library/HandleParsingLib.h @@ -1,7 +1,7 @@ /** @file Provides interface to advanced shell functionality for parsing both handle and protocol database. - Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -388,4 +388,23 @@ GetHandleListByProtocolList ( IN CONST EFI_GUID **ProtocolGuids ); + +/** + Return all supported GUIDs. + + @param[out] Guids The buffer to return all supported GUIDs. + @param[in out] Count On input, the count of GUIDs the buffer can hold, + On output, the count of GUIDs to return. + + @retval EFI_INVALID_PARAMETER Count is NULL. + @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs. + @retval EFI_SUCCESS GUIDs are returned successfully. +**/ +EFI_STATUS +EFIAPI +GetAllMappingGuids ( + OUT EFI_GUID *Guids, + IN OUT UINTN *Count + ); + #endif // __HANDLE_PARSING_LIB__ diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 780c458..b4cd1b3 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -3079,3 +3079,55 @@ GetHandleListByProtocolList ( return (HandleList); } + +/** + Return all supported GUIDs. + + @param[out] Guids The buffer to return all supported GUIDs. + @param[in, out] Count On input, the count of GUIDs the buffer can hold, + On output, the count of GUIDs to return. + + @retval EFI_INVALID_PARAMETER Count is NULL. + @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs. + @retval EFI_SUCCESS GUIDs are returned successfully. +**/ +EFI_STATUS +EFIAPI +GetAllMappingGuids ( + OUT EFI_GUID *Guids, + IN OUT UINTN *Count + ) +{ + UINTN GuidCount; + UINTN NtGuidCount + UINTN Index; + + if (Count == NULL) { + return EFI_INVALID_PARAMETER; + } + + NtGuidCount = 0; + if (PcdGetBool (PcdShellIncludeNtGuids)) { + NtGuidCount = ARRAY_SIZE (mGuidStringListNT) - 1; + } + GuidCount = ARRAY_SIZE (mGuidStringList) - 1; + + if (*Count < NtGuidCount + GuidCount + mGuidListCount) { + *Count = NtGuidCount + GuidCount + mGuidListCount; + return EFI_BUFFER_TOO_SMALL; + } + + for (Index = 0; Index < NtGuidCount; Index++) { + CopyGuid (&Guids[Index], mGuidStringListNT[Index].GuidId); + } + + for (Index = 0; Index < GuidCount; Index++) { + CopyGuid (&Guids[NtGuidCount + Index], mGuidStringList[Index].GuidId); + } + + for (Index = 0; Index < mGuidListCount; Index++) { + CopyGuid (&Guids[NtGuidCount + GuidCount + Index], mGuidList[Index].GuidId); + } + + return EFI_SUCCESS; +} -- 2.9.0.windows.1