From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.17150.1683249324105575349 for ; Thu, 04 May 2023 18:15:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=BMNkgxnK; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.236.40, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0gRZM9BoNxggNuf40f61Ghd20bEfHViIuXUaeKDPU7FClTnsEFfUtIuJugu0Gr3wSriWYwacgox1pOJeW3H19gRitxztoxjPSqGdDtEWTmO0ab5o2f/6NTt/ekNBP3sKE+P+DBUgR5dakTODhKGfMj45pCBCZ60VfHAg+OGW1ECUcOTXGcWAxbOlWxNZKCy58yBjnoMj02KNMAW450ViAz+T0g4hjjbr9pdSFYJ7FyZ6MZujZo9TcVY+T5V7sfWXVxhvKiIev8hzOO69NmDwh85PHh/vWSn+exhADzzJ8pmcUVYnsdqLF/loGekijAYuAa+7CCLRG8u6S4bictRJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HFrjh27iV5D4pRZvCCedGcoCKoj9W9OqvHncOROeLKk=; b=T41ahMTncQIbtLZ8MTYlYaU6sJyaS37Vb8JZrh7OI5B0/xIFKz0uDI9ShcyXGUedKaDSgrbElIQe20G4SN9bhcvMxCF33XC8oNPIUVqfGFrq8uaORqxcqQKUFEz73TxoEwFsXK60pLMwwyKVf2rYdfsYVI4YlCAzgZEGzsp4rClvLbNiYoCECPe839H7yqWJD45hzd39dURPJsgovZ6/ICXlqI8i1JLy+HN/AhSTMpcXvAv4Ao/BN65gdm9y8jHbxCqBjVzpZVdDweV4JcR3JITnJRPMujRsnTTGbvVyvyxkK56r/jF0AKLSxLMDEDjRej/k4xdFLWlGbvVteSr0vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HFrjh27iV5D4pRZvCCedGcoCKoj9W9OqvHncOROeLKk=; b=BMNkgxnKZdkY68Mra0wPteBpDzqi+kdeqkCZm+J+9bahC9l2X8TBFiu3Gw/f70KsYlj8xzRxNkycD4/1cZIYkmC2ILikdmHMRQdilnoP2cjocZYiOkem8PSLizYKi90qTyixL5SIYii++lgBvN1lbF3OFuTx13eTYs8sAc2Mek0= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by CY8PR12MB7338.namprd12.prod.outlook.com (2603:10b6:930:52::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26; Fri, 5 May 2023 01:15:20 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3%3]) with mapi id 15.20.6363.027; Fri, 5 May 2023 01:15:20 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [edk2-redfish-client][PATCH 6/8] RedfishClientPkg: Add Redfish Feature Utility library Thread-Topic: [edk2-redfish-client][PATCH 6/8] RedfishClientPkg: Add Redfish Feature Utility library Thread-Index: AQHZfpRcNOIqOlAW/kSuLdcRQJCbdq9K4OUA Date: Fri, 5 May 2023 01:15:20 +0000 Message-ID: References: <20230504142540.17996-1-nicklew@nvidia.com> In-Reply-To: <20230504142540.17996-1-nicklew@nvidia.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-05-05T01:15:18Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=00431856-4304-42af-a296-6329002241d1; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|CY8PR12MB7338:EE_ x-ms-office365-filtering-correlation-id: 428d3391-61d7-4c41-b3ea-08db4d0631fd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fEuRU9Wxu7Z98OkzmiarJquwKXN+FGgMHC6NbAcFAJQGdiRtV/7mLEdlDF5lbSqlm51s+MmxWd2k58fscE6PJWDIWrkIRo/Iv864ogTOrxFx+8/hYjIh1SXtDpFr/zzlZ6Tga94zdt/UziUjCdWvMnCzNdooTwWQM8PyNG0M11IoObFmKq3XIO0NWtxOpisV/CMCnwiUVtqueS0hw48lwq5NED5dqmPYX8SOSlT2juQIm4hQN63ne7AAK5lUSNpH2SfZK22iemt34P6N7cx72/I6WznwnJCOhHV6fhgEqwhbAkDLpo+O2YmLdsEnxEAxg/NQDEzepqWam6PI1BfYlVViet9dHFQMcN0m4CMKCj6iFGPwDonvUcy1Tv7B6j2Mq0lg+gxQio9TZzYEWc2WcV+G8F1ni9iLZqeTWVL0VydaZNifVxcHytIdgiJDJ+HdTEftaD4sqhXd4oT6exYN+9WRkpt+RY1wn7ow4El81aM3nOMi5VdTrsQImGl6jMbDKmZv9OvRgYL+Zm0qvxNWU6k0Ep6n0+iLAv6FLI7+e0MHzbZipO90vAWOy6MXhYmfYtk0wrwOg5c13w5Yp86PnOX3uvfPnO5mretMoaaoYW0xKedewrUNeNyiVbkC7T21 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(376002)(346002)(39860400002)(136003)(451199021)(52536014)(7696005)(33656002)(122000001)(41300700001)(8936002)(8676002)(86362001)(83380400001)(5660300002)(53546011)(9686003)(4326008)(26005)(6506007)(478600001)(71200400001)(316002)(76116006)(38100700002)(66556008)(66446008)(66476007)(64756008)(66946007)(2906002)(30864003)(38070700005)(186003)(55016003)(110136005)(559001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Yo/DYJYa8If6/YYyXhtalpWk9I6FgRIa0QzLMK3UU/lv1zpiCsDQdUVKeTNf?= =?us-ascii?Q?K+f/dvCguXhVEsvsB4jkEEArO2SSxDzhLJmNVOmBNyHVRPXVmfJsPh4qFbpw?= =?us-ascii?Q?8PqPcA4BOwzs2s036kcq5jz07VMclndJEKPgjmqtrdBb6XAxwVQam3DbN4iQ?= =?us-ascii?Q?YTAeiPMsFuxK6kTnL0NS+sRRM228mn259orVMTWd5WfxpQxuzXdGnEZQoJjF?= =?us-ascii?Q?ue4cpP9REEPEJSC5r5CQ5Qp11+ho/AfRQQzr/RJpvlBzVS/j42uRjLIUptrG?= =?us-ascii?Q?uoBmUCP0A/8ZSDmgrrZfBuRKpa/FTu9XgK1+uiTXjmzArQxX0SgGGQ0gH07g?= =?us-ascii?Q?RW/5goG508LAVsk78KZ0xsWoJeUc7IZYthcHhEsYc4bHkWR7G3dFphELGLro?= =?us-ascii?Q?CzDvSKiCRcEgwio4YEDjoa+RQWMTO36nC1cM+MrcqFqWIeq9NHa3hl7qIQQN?= =?us-ascii?Q?rzOu9MNoAeZtSyLOpyhX/QSIjXoSEA+GMog9PGYWKZai1YKrQXVhCdMjIKs1?= =?us-ascii?Q?YTvWWkQyFPvfWeExqcxWeT35zmemGv/PqyjT52RhX/BL61O43NrzUhKYZnTF?= =?us-ascii?Q?B3+L9X837IcIPDNZCSBk4x/h8lggVKwGGYd5yVvp84tRI42VbVRu4j5ejd3e?= =?us-ascii?Q?Y63CbwF0HRLIATjsGqdX2E79PgOsrjm5dJaGhUNesmSyUOlOCPoQ74ADMf23?= =?us-ascii?Q?mtD7yyXHETKkIu9ki5gjQ5k9wJMny8OVH/qUoJ2Trim9NN8HoKHNqYSZ5wqj?= =?us-ascii?Q?oRVcI2LJViT2eYFdV00/XQsMqegVs6Jf+dFiohGC3SQf6ibmpkpi+v9lMoTj?= =?us-ascii?Q?OMDOyn2OVnPoNjLdoCpEUAs7HEOYhkPhq8mSddoNhxkaVMvQs2AsKP1475mz?= =?us-ascii?Q?5cW3rBZrthg4eE8GPD+WqQkrvXaIw+zD10MGRpP+ewqvPckcvRuQDf4mt3Xg?= =?us-ascii?Q?wZ6iRepU4lnOXHwdY7Fd14/od5/cTale52L3OLWKcuV+uZi/iT33yKx4eNzC?= =?us-ascii?Q?KECsaWC+/yvq24zyQglGf/F5wV6UO/SZLDBYag4cY6Ot2GYHV86KqPI8UgIX?= =?us-ascii?Q?l9wenJKZ6qQbracmRLFiJjRsrqC+zWRUJuuWW2gHRKAdjmYJ8Z5NkFGN/RMy?= =?us-ascii?Q?bnqtxGHbrjPhHRB7vKSch05OjmGUZEH3V2x9lodsE/kZKVJxuARc1IwFsTks?= =?us-ascii?Q?ElNnKHzz5muLwOi9eTxzN1XNLgWonvlIYiQfDuQC9onXPzDdrfKuA5aCSRuy?= =?us-ascii?Q?no2/wgigFjc7Z4No7WLe1zv/S/Db+JRQttCDKd2iCjy10Tzcjfpy0W+d0gf4?= =?us-ascii?Q?AFQTe74E4ycoC/uf+3EpZDI/IalDknYBwu/yEQjVYpM1Z4XR74DYtb93aRla?= =?us-ascii?Q?Zkg+h4kcV+1Fy2trL7Sg+CI94R5WYem3bhcxD3DGh7FadjzP04xOpTaGrzto?= =?us-ascii?Q?odLYWieCoMdwksnTr4V1OUX9eeTK4LpjY8Fs3gtoGxoghbb67WCRym4989n3?= =?us-ascii?Q?FAgqQCMgwFMLu2SoM867YSvqNsq3h0eTCynjO5/H7llRMntYlB79m73PGP7F?= =?us-ascii?Q?MfkHqesPbSi/F3VU2YIu5zzD0K+oHv03YfJ9/Ycw?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 428d3391-61d7-4c41-b3ea-08db4d0631fd X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2023 01:15:20.6642 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4V1AYaCm6tSutpd7P5PuCsNQrGLDI5Y+YtJWnrLA+wGk6DB9DUGqaXYltECfsyaYXVnFypd5m8/aTuws/tAEag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7338 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Thursday, May 4, 2023 10:26 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > > Subject: [edk2-redfish-client][PATCH 6/8] RedfishClientPkg: Add Redfish > Feature Utility library >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > This is the helper library for EDKII Redfish feature drivers to > manipulate Redfish properties. >=20 > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > --- > RedfishClientPkg/RedfishClientPkg.dec | 3 + > RedfishClientPkg/RedfishClientLibs.dsc.inc | 3 + > RedfishClientPkg/RedfishClientPkg.dsc | 2 + > .../RedfishFeatureUtilityLib.inf | 50 + > .../Library/RedfishFeatureUtilityLib.h | 471 +++++ > .../RedfishFeatureUtilityInternal.h | 45 + > .../RedfishFeatureUtilityLib.c | 1513 +++++++++++++++++ > 7 files changed, 2087 insertions(+) > create mode 100644 > RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLi= b.i > nf > create mode 100644 > RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > create mode 100644 > RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityIn= ter > nal.h > create mode 100644 > RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLi= b.c >=20 > diff --git a/RedfishClientPkg/RedfishClientPkg.dec > b/RedfishClientPkg/RedfishClientPkg.dec > index f0fe3269..b965f915 100644 > --- a/RedfishClientPkg/RedfishClientPkg.dec > +++ b/RedfishClientPkg/RedfishClientPkg.dec > @@ -19,6 +19,9 @@ > PrivateInclude # Private header files > PrivateInclude/Crt # Private header files for C RTL. >=20 > +[LibraryClasses] > + RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h > + > [Protocols] > ## Include/Protocol/EdkIIRedfishFeature.h > gEdkIIRedfishFeatureProtocolGuid =3D { 0x785CC694, 0x4930, 0xEF= BF, > { 0x2A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0xAA, 0x34 } } > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index 7e313ae5..a5ae73ca 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -14,3 +14,6 @@ > !include RedfishClientPkg/RedfishJsonStructureLib.dsc.inc > !endif >=20 > + > RedfishFeatureUtilityLib|RedfishClientPkg/Library/RedfishFeatureUtilityLi= b/ > RedfishFeatureUtilityLib.inf > + > RedfishPlatformConfigLib|RedfishPkg/Library/RedfishPlatformConfigLib/Red > fishPlatformConfigLib.inf > + > diff --git a/RedfishClientPkg/RedfishClientPkg.dsc > b/RedfishClientPkg/RedfishClientPkg.dsc > index adb50cec..00a963ea 100644 > --- a/RedfishClientPkg/RedfishClientPkg.dsc > +++ b/RedfishClientPkg/RedfishClientPkg.dsc > @@ -47,4 +47,6 @@ >=20 > [Components] >=20 > + > RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLi= b.i > nf > + > !include RedfishClientPkg/RedfishClient.dsc.inc > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib > .inf > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib > .inf > new file mode 100644 > index 00000000..f9f283fd > --- /dev/null > +++ > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib > .inf > @@ -0,0 +1,50 @@ > +## @file > +# > +# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development > LP
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010006 > + BASE_NAME =3D RedfishFeatureUtilityLib > + FILE_GUID =3D 8BBE1212-A4BF-4ECA-B89B-8F85F83CC9B= 7 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RedfishFeatureUtilityLib| DXE_DRIVE= R > DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER > + CONSTRUCTOR =3D RedfishFeatureUtilityLibConstructor > + DESTRUCTOR =3D RedfishFeatureUtilityLibDestructor > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 EBC > +# > + > +[Sources] > + RedfishFeatureUtilityLib.c > + RedfishFeatureUtilityInternal.h > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + RedfishClientPkg/RedfishClientPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + MemoryAllocationLib > + PrintLib > + RedfishLib > + RedfishPlatformConfigLib > + UefiLib > + UefiBootServicesTableLib > + UefiRuntimeServicesTableLib > + > +[Protocols] > + gEdkIIRedfishETagProtocolGuid ## CONSUMED ## > + > +[Pcd] > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize > diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > new file mode 100644 > index 00000000..928fa4e8 > --- /dev/null > +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h > @@ -0,0 +1,471 @@ > +/** @file > + This file defines the Redfish Feature Utility Library interface. > + > + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef REDFISH_FEATURE_UTILITY_LIB_H_ > +#define REDFISH_FEATURE_UTILITY_LIB_H_ > + > +#include > +#include > + > +// > +// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG > +// > +typedef struct { > + UINTN Index; > + EFI_STRING ConfigureLang; > +} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG; > + > +// > +// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST > +// > +typedef struct { > + UINTN Count; > + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG *List; > +} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST; > + > +/** > + > + Read redfish resource by given resource path. > + > + @param[in] Service Redfish srvice instacne to make query. > + @param[in] ResourcePath Target resource path. > + @param[out] Response HTTP response from redfish service. > + > + @retval EFI_SUCCESS Resrouce is returned successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetResourceByPath ( > + IN REDFISH_SERVICE *Service, > + IN CHAR8 *ResourcePath, > + OUT REDFISH_RESPONSE *Response > + ); > + > +/** > + > + Search HII database with given Configure Language pattern. Data is > handled and > + returned in array. > + > + @param[in] Schema The schema to search. > + @param[in] Version The schema version. > + @param[in] Pattern Configure Language pattern to se= arch. > + @param[out] UnifiedConfigureLangList The data returned by HII databas= e. > + > + @retval EFI_SUCCESS Data is found and returned. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +RedfishFeatureGetUnifiedArrayTypeConfigureLang ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING Pattern, > + OUT REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST > *UnifiedConfigureLangList > + ); > + > +/** > + > + Get array key by parsing the URI. > + > + @param[in] Uri URI with array key. > + @param[out] ArrayKey Array key in given URI string. > + > + @retval EFI_SUCCESS Array key is found. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetArraykeyFromUri ( > + IN CHAR8 *Uri, > + OUT CHAR8 **ArrayKey > + ); > + > +/** > + > + Keep configure language with given key in UEFI variable. > + > + @param[in] Schema Schema name. > + @param[in] Version Schema version. > + @param[in] Key Key string. > + @param[in] ConfigureLangIndex Index value. > + > + @retval EFI_SUCCESS Data is saved in UEFI variable. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +SetConfigureLangWithkey ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *Key, > + IN UINTN ConfigureLangIndex > + ); > + > +/** > + > + Find configure language with input key string. > + > + @param[in] Schema Schema name. > + @param[in] Version Schema version. > + @param[in] Property Property name. > + @param[in] Key Key string. > + > + @retval CHAR16 * Corresponding configure langauge > + @retval NULL No configure language is found > + > +**/ > +CHAR16 * > +GetConfigureLangByKey ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *Property, > + IN CHAR8 *Key > + ); > + > +/** > + > + Convert HII string value to string value in JSON format. > + > + @param[in] HiiStringValue String in HII format. > + > + @retval CHAR8 * String in JSON format. > + @retval NULL Errors occur. > + > +**/ > +CHAR8 * > +ConvertHiiStringValueToJsonStringValue ( > + IN EFI_STRING HiiStringValue > + ); > + > +/** > + > + Apply property value to UEFI HII database in string type. > + > + @param[in] Schema Property schema. > + @param[in] Version Property schema version. > + @param[in] ConfigureLang Configure language refers to this property. > + @param[in] FeatureValue New value to set. > + > + @retval EFI_SUCCESS New value is applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +ApplyFeatureSettingsStringType ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING ConfigureLang, > + IN CHAR8 *FeatureValue > + ); > + > +/** > + > + Apply property value to UEFI HII database in numric type. > + > + @param[in] Schema Property schema. > + @param[in] Version Property schema version. > + @param[in] ConfigureLang Configure language refers to this property. > + @param[in] FeatureValue New value to set. > + > + @retval EFI_SUCCESS New value is applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +ApplyFeatureSettingsNumericType ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING ConfigureLang, > + IN INTN FeatureValue > + ); > + > +/** > + > + Apply property value to UEFI HII database in boolean type. > + > + @param[in] Schema Property schema. > + @param[in] Version Property schema version. > + @param[in] ConfigureLang Configure language refers to this property. > + @param[in] FeatureValue New value to set. > + > + @retval EFI_SUCCESS New value is applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +ApplyFeatureSettingsBooleanType ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING ConfigureLang, > + IN BOOLEAN FeatureValue > + ); > + > +/** > + > + Create HTTP payload and send them to redfish service with POST method. > + > + @param[in] Service Redfish service. > + @param[in] TargetPayload Target payload > + @param[in] Json Data in JSON format. > + @param[out] Location Returned location string from Redfish serv= ice. > + @param[out] Etag Returned ETAG string from Redfish service. > + > + @retval EFI_SUCCESS Data is sent to redfish service successful= ly. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +CreatePayloadToPostResource ( > + IN REDFISH_SERVICE *Service, > + IN REDFISH_PAYLOAD *TargetPayload, > + IN CHAR8 *Json, > + OUT CHAR8 **Location, > + OUT CHAR8 **Etag > + ); > + > +/** > + > + Create HTTP payload and send them to redfish service with PATCH method= . > + > + @param[in] Service Redfish service. > + @param[in] TargetPayload Target payload > + @param[in] Json Data in JSON format. > + @param[out] Etag Returned ETAG string from Redfish service. > + > + @retval EFI_SUCCESS Data is sent to redfish service successful= ly. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +CreatePayloadToPatchResource ( > + IN REDFISH_SERVICE *Service, > + IN REDFISH_PAYLOAD *TargetPayload, > + IN CHAR8 *Json, > + OUT CHAR8 **Etag > + ); > + > +/** > + > + Find Redfish Resource Config Protocol that supports given schema and > version. > + > + @param[in] Schema Schema name. > + @param[in] Major Schema version major number. > + @param[in] Minor Schema version minor number. > + @param[in] Errata Schema version errata number. > + > + @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to > protocol > + @retval NULL No protocol fo= und. > + > +**/ > +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * > +GetRedfishResourceConfigProtocol ( > + IN CHAR8 *Schema, > + IN CHAR8 *Major, > + IN CHAR8 *Minor, > + IN CHAR8 *Errata > + ); > + > +/** > + > + Get supported schema list by given specify schema name. > + > + @param[in] Schema Schema type name. > + @param[out] SchemaInfo Returned schema information. > + > + @retval EFI_SUCCESS Schema information is returned success= fully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetSupportedSchemaVersion ( > + IN CHAR8 *Schema, > + OUT REDFISH_SCHEMA_INFO *SchemaInfo > + ); > + > +/** > + > + Return system root path > + > + @retval NULL Can not find system root path. > + @retval Other System root path is returned. > + > +**/ > +CHAR8 * > +RedfishGetSystemRootPath ( > + VOID > + ); > + > +/** > + > + Get schema information by given protocol and service instance. > + > + @param[in] RedfishService Pointer to Redfish service instance. > + @param[in] JsonStructProtocol Json Structure protocol instance. > + @param[in] Uri Target URI. > + @param[out] SchemaInfo Returned schema information. > + > + @retval EFI_SUCCESS Schema information is returned success= fully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetRedfishSchemaInfo ( > + IN REDFISH_SERVICE *RedfishService, > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, > + IN CHAR8 *Uri, > + OUT REDFISH_SCHEMA_INFO *SchemaInfo > + ); > + > +/** > + > + Get the property name by given Configure Langauge. > + > + @param[in] ConfigureLang Configure Language string. > + > + @retval EFI_STRING Pointer to property name. > + @retval NULL There is error. > + > +**/ > +EFI_STRING > +GetPropertyFromConfigureLang ( > + IN EFI_STRING ConfigureLang > + ); > + > +/** > + > + Get the property value in string type. > + > + @param[in] Schema Schema of this property. > + @param[in] Version Schema version. > + @param[in] PropertyName Property name. > + @param[in] ConfigureLang Configure Language of this property. > + > + @retval CHAR8* Pointer to the CHAR8 buffer. > + @retval NULL There is error. > + > +**/ > +CHAR8 * > +GetPropertyStringValue ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING PropertyName, > + IN EFI_STRING ConfigureLang > + ); > + > +/** > + > + Get the property value in numeric type. > + > + @param[in] Schema Schema of this property. > + @param[in] Version Schema version. > + @param[in] PropertyName Property name. > + @param[in] ConfigureLang Configure Language of this property. > + > + @retval INT64* Pointer to the INT64 value. > + @retval NULL There is error. > + > +**/ > +INT64 * > +GetPropertyNumericValue ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING PropertyName, > + IN EFI_STRING ConfigureLang > + ); > + > +/** > + > + Get the property value in Boolean type. > + > + @param[in] Schema Schema of this property. > + @param[in] Version Schema version. > + @param[in] PropertyName Property name. > + @param[in] ConfigureLang Configure Language of this property. > + > + @retval BOOLEAN Boolean value returned by this property. > + > +**/ > +BOOLEAN * > +GetPropertyBooleanValue ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING PropertyName, > + IN EFI_STRING ConfigureLang > + ); > + > +/** > + > + Check and see if we need to do provisioning for this property. > + > + @param[in] PropertyBuffer Pointer to property instance. > + @param[in] ProvisionMode TRUE if we are in provision mode. FALSE > otherwise. > + > + @retval TRUE Provision is required. > + @retval FALSE Provision is not required. > + > +**/ > +BOOLEAN > +PropertyChecker ( > + IN VOID *PropertyBuffer, > + IN BOOLEAN ProvisionMode > + ); > + > +/** > + > + Check and see if we need to do provisioning for this two properties. > + > + @param[in] PropertyBuffer1 Pointer to property instance 1. > + @param[in] PropertyBuffer2 Pointer to property instance 2. > + @param[in] ProvisionMode TRUE if we are in provision mode. FALSE > otherwise. > + > + @retval TRUE Provision is required. > + @retval FALSE Provision is not required. > + > +**/ > +BOOLEAN > +PropertyChecker2Parm ( > + IN VOID *PropertyBuffer1, > + IN VOID *PropertyBuffer2, > + IN BOOLEAN ProvisionMode > + ); > + > +/** > + > + Keep ETAG string and URI string in database. > + > + @param[in] EtagStr ETAG string. > + @param[in] Uri URI string. > + > + @retval EFI_SUCCESS ETAG and URI are applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +SetEtagWithUri ( > + IN CHAR8 *EtagStr, > + IN CHAR8 *Uri > + ); > + > +/** > + > + Find ETAG string that refers to given URI. > + > + @param[in] Uri Target URI string. > + > + @retval CHAR8 * ETAG string > + @retval NULL No ETAG is found. > + > +**/ > +CHAR8 * > +GetEtagWithUri ( > + IN CHAR8 *Uri > + ); > + > +#endif > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Int > ernal.h > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Int > ernal.h > new file mode 100644 > index 00000000..cfb9759a > --- /dev/null > +++ > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Int > ernal.h > @@ -0,0 +1,45 @@ > +/** @file > + Common header file for RedfishFeatureUtilityLib driver. > + > + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef REDFISH_FEATURE_INTERNAL_H_ > +#define REDFISH_FEATURE_INTERNAL_H_ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include > + > +#define INDEX_VARIABLE_SIZE 64 > +#define INDEX_STRING_SIZE 16 > +#define IS_EMPTY_STRING(a) (a =3D=3D NULL || a[0] =3D=3D '\0') > +#define INDEX_STRING L"{%d}" > +#define SCHEMA_NAME_PREFIX_OFFSET 15// x-uefi-redfish- > +#define REDFISH_SYSTEM_ROOT_PATH "/v1/Systems[UUID~%g]" > +#define MAX_CONF_LANG_LEN 128 > + > +#define BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_START_SIGNATURE > L"{" > +#define BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_END_SIGNATURE > L"}" > +#define BIOS_CONFIG_TO_REDFISH_REDPATH_POOL_SIZE 64 > + > +#endif > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib > .c > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib > .c > new file mode 100644 > index 00000000..605283b9 > --- /dev/null > +++ > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib > .c > @@ -0,0 +1,1513 @@ > +/** @file > + Redfish feature utility library implementation > + > + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "RedfishFeatureUtilityInternal.h" > + > +EDKII_REDFISH_ETAG_PROTOCOL *mEtagProtocol; > + > +/** > + > + Get array key by parsing the URI. > + > + @param[in] Uri URI with array key. > + @param[out] ArrayKey Array key in given URI string. > + > + @retval EFI_SUCCESS Array key is found. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetArraykeyFromUri ( > + IN CHAR8 *Uri, > + OUT CHAR8 **ArrayKey > + ) > +{ > + CHAR8 *LeftBracket; > + UINTN Index; > + > + if (IS_EMPTY_STRING (Uri) || (ArrayKey =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + *ArrayKey =3D NULL; > + > + // > + // Loop through Uri and find last '[' > + // > + LeftBracket =3D NULL; > + for (Index =3D 0; Uri[Index] !=3D '\0'; Index++) { > + if (Uri[Index] =3D=3D '[') { > + LeftBracket =3D &Uri[Index]; > + } > + } > + > + if (LeftBracket =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + // > + // skip '/' > + // > + ++LeftBracket; > + > + *ArrayKey =3D AllocateCopyPool (AsciiStrSize (LeftBracket), LeftBracke= t); > + if (*ArrayKey =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + // > + // remove ']' > + // > + *(*ArrayKey + AsciiStrLen (*ArrayKey) - 1) =3D '\0'; > + > + return EFI_SUCCESS; > +} > + > +/** > + > + Keep configure language with given key in UEFI variable. > + > + @param[in] Schema Schema name. > + @param[in] Version Schema version. > + @param[in] Key Key string. > + @param[in] ConfigureLangIndex Index value. > + > + @retval EFI_SUCCESS Data is saved in UEFI variable. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +SetConfigureLangWithkey ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *Key, > + IN UINTN ConfigureLangIndex > + ) > +{ > + CHAR16 IndexString[INDEX_STRING_SIZE]; > + CHAR16 VarName[INDEX_VARIABLE_SIZE]; > + CHAR16 *VarData; > + EFI_STATUS Status; > + > + // > + // Variable content. > + // > + UnicodeSPrint (IndexString, sizeof (IndexString), INDEX_STRING, > ConfigureLangIndex); > + > + // > + // Variable name. > + // > + UnicodeSPrint (VarName, sizeof (VarName), L"%a_%a_%a", Schema, > Version, Key); > + > + // > + // Check if it exists already. > + // > + Status =3D GetVariable2 ( > + VarName, > + &gEfiCallerIdGuid, > + (VOID *)&VarData, > + NULL > + ); > + if (!EFI_ERROR (Status)) { > + DEBUG ((DEBUG_INFO, "%a, remove stale data: %s\n", __FUNCTION__, > VarData)); > + FreePool (VarData); > + gRT->SetVariable (VarName, &gEfiCallerIdGuid, > VARIABLE_ATTRIBUTE_NV_BS, 0, NULL); > + } > + > + return gRT->SetVariable (VarName, &gEfiCallerIdGuid, > VARIABLE_ATTRIBUTE_NV_BS, StrSize (IndexString), (VOID *)&IndexString); > +} > + > +/** > + > + Find configure language with input key string. > + > + @param[in] Schema Schema name. > + @param[in] Version Schema version. > + @param[in] Property Property name. > + @param[in] Key Key string. > + > + @retval CHAR16 * Corresponding configure langauge > + @retval NULL No configure language is found > + > +**/ > +CHAR16 * > +GetConfigureLangByKey ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN CHAR8 *Property, OPTIONAL > + IN CHAR8 *Key > + ) > +{ > + EFI_STATUS Status; > + CHAR16 VariableName[64]; > + UINTN VariableSize; > + CHAR16 *CollectionIndex; > + CHAR16 *ConfigureLang; > + UINTN ConfigureLangLen; > + > + if ((Schema =3D=3D NULL) || (Version =3D=3D NULL) || (Key =3D=3D NULL)= ) { > + return NULL; > + } > + > + CollectionIndex =3D NULL; > + ConfigureLang =3D NULL; > + > + UnicodeSPrint (VariableName, 64, L"%a_%a_%a", Schema, Version, Key); > + > + Status =3D GetVariable2 ( > + VariableName, > + &gEfiCallerIdGuid, > + (VOID *)&CollectionIndex, > + &VariableSize > + ); > + if (EFI_ERROR (Status)) { > + return NULL; > + } > + > + ConfigureLangLen =3D AsciiStrLen (Schema) + StrLen (CollectionIndex) + > (Property =3D=3D NULL ? 0 : AsciiStrLen (Property)) + 3 + 1; > + ConfigureLang =3D AllocatePool (sizeof (CHAR16) * ConfigureLangLen)= ; > + ASSERT (ConfigureLang); > + > + if (Property !=3D NULL) { > + UnicodeSPrint (ConfigureLang, sizeof (CHAR16) * ConfigureLangLen, > L"/%a/%s/%a", Schema, CollectionIndex, Property); > + } else { > + UnicodeSPrint (ConfigureLang, sizeof (CHAR16) * ConfigureLangLen, > L"/%a/%s", Schema, CollectionIndex); > + } > + > + FreePool (CollectionIndex); > + > + return ConfigureLang; > +} > + > +/** > + > + Keep ETAG string and URI string in database. > + > + @param[in] EtagStr ETAG string. > + @param[in] Uri URI string. > + > + @retval EFI_SUCCESS ETAG and URI are applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +SetEtagWithUri ( > + IN CHAR8 *EtagStr, > + IN CHAR8 *Uri > + ) > +{ > + EFI_STATUS Status; > + > + if (IS_EMPTY_STRING (EtagStr) || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (mEtagProtocol =3D=3D NULL) { > + Status =3D gBS->LocateProtocol ( > + &gEdkIIRedfishETagProtocolGuid, > + NULL, > + (VOID **)&mEtagProtocol > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + } > + > + mEtagProtocol->Set (mEtagProtocol, Uri, EtagStr); > + mEtagProtocol->Flush (mEtagProtocol); > + > + return EFI_SUCCESS; > +} > + > +/** > + > + Find ETAG string that refers to given URI. > + > + @param[in] Uri Target URI string. > + > + @retval CHAR8 * ETAG string > + @retval NULL No ETAG is found. > + > +**/ > +CHAR8 * > +GetEtagWithUri ( > + IN CHAR8 *Uri > + ) > +{ > + EFI_STATUS Status; > + CHAR8 *EtagStr; > + > + if (IS_EMPTY_STRING (Uri)) { > + return NULL; > + } > + > + if (mEtagProtocol =3D=3D NULL) { > + Status =3D gBS->LocateProtocol ( > + &gEdkIIRedfishETagProtocolGuid, > + NULL, > + (VOID **)&mEtagProtocol > + ); > + if (EFI_ERROR (Status)) { > + return NULL; > + } > + } > + > + Status =3D mEtagProtocol->Get (mEtagProtocol, Uri, &EtagStr); > + if (EFI_ERROR (Status)) { > + return NULL; > + } > + > + return EtagStr; > +} > + > +/** > + > + Convert HII string value to string value in JSON format. > + > + @param[in] HiiStringValue String in HII format. > + > + @retval CHAR8 * String in JSON format. > + @retval NULL Errors occur. > + > +**/ > +CHAR8 * > +ConvertHiiStringValueToJsonStringValue ( > + IN EFI_STRING HiiStringValue > + ) > +{ > + CHAR8 *JsonValue; > + UINTN JsonValueSize; > + > + if (IS_EMPTY_STRING (HiiStringValue)) { > + return NULL; > + } > + > + JsonValueSize =3D StrLen (HiiStringValue) + 1; > + JsonValue =3D AllocatePool (JsonValueSize); > + UnicodeStrToAsciiStrS (HiiStringValue, JsonValue, JsonValueSize); > + > + return JsonValue; > +} > + > +/** > + > + Apply property value to UEFI HII database in string type. > + > + @param[in] Schema Property schema. > + @param[in] Version Property schema version. > + @param[in] ConfigureLang Configure language refers to this property. > + @param[in] FeatureValue New value to set. > + > + @retval EFI_SUCCESS New value is applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +ApplyFeatureSettingsStringType ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING ConfigureLang, > + IN CHAR8 *FeatureValue > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_VALUE RedfishValue; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > IS_EMPTY_STRING (ConfigureLang) || (FeatureValue =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Get the current value from HII > + // > + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLa= ng, > &RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, > Schema, Version, ConfigureLang, Status)); > + } else { > + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_STRING) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string type\n", > __FUNCTION__, Schema, Version, ConfigureLang)); > + return EFI_DEVICE_ERROR; > + } > + > + if (AsciiStrCmp (FeatureValue, RedfishValue.Value.Buffer) !=3D 0) { > + // > + // Apply settings from redfish > + // > + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s from %a to %a\n", > __FUNCTION__, Schema, Version, ConfigureLang, > RedfishValue.Value.Buffer, FeatureValue)); > + > + FreePool (RedfishValue.Value.Buffer); > + RedfishValue.Value.Buffer =3D FeatureValue; > + > + Status =3D RedfishPlatformConfigSetValue (Schema, Version, > ConfigureLang, RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, apply %s to %s failed: %r\n", > __FUNCTION__, ConfigureLang, FeatureValue, Status)); > + } > + } else { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is: %s\n", > __FUNCTION__, Schema, Version, ConfigureLang, > RedfishValue.Value.Buffer, Status)); > + } > + } > + > + return Status; > +} > + > +/** > + > + Apply property value to UEFI HII database in numric type. > + > + @param[in] Schema Property schema. > + @param[in] Version Property schema version. > + @param[in] ConfigureLang Configure language refers to this property. > + @param[in] FeatureValue New value to set. > + > + @retval EFI_SUCCESS New value is applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +ApplyFeatureSettingsNumericType ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING ConfigureLang, > + IN INTN FeatureValue > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_VALUE RedfishValue; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > IS_EMPTY_STRING (ConfigureLang)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Get the current value from HII > + // > + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLa= ng, > &RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, > Schema, Version, ConfigureLang, Status)); > + } else { > + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_INTEGER) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not numeric type\n", > __FUNCTION__, Schema, Version, ConfigureLang)); > + return EFI_DEVICE_ERROR; > + } > + > + if (RedfishValue.Value.Integer !=3D FeatureValue) { > + // > + // Apply settings from redfish > + // > + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s from 0x%x to 0x%x\n", > __FUNCTION__, Schema, Version, ConfigureLang, > RedfishValue.Value.Integer, FeatureValue)); > + > + RedfishValue.Value.Integer =3D (INT64)FeatureValue; > + > + Status =3D RedfishPlatformConfigSetValue (Schema, Version, > ConfigureLang, RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, apply %s to 0x%x failed: %r\n", > __FUNCTION__, ConfigureLang, FeatureValue, Status)); > + } > + } else { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is: 0x%x\n", > __FUNCTION__, Schema, Version, ConfigureLang, > RedfishValue.Value.Integer, Status)); > + } > + } > + > + return Status; > +} > + > +/** > + > + Apply property value to UEFI HII database in boolean type. > + > + @param[in] Schema Property schema. > + @param[in] Version Property schema version. > + @param[in] ConfigureLang Configure language refers to this property. > + @param[in] FeatureValue New value to set. > + > + @retval EFI_SUCCESS New value is applied successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +ApplyFeatureSettingsBooleanType ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING ConfigureLang, > + IN BOOLEAN FeatureValue > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_VALUE RedfishValue; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > IS_EMPTY_STRING (ConfigureLang)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Get the current value from HII > + // > + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLa= ng, > &RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, > Schema, Version, ConfigureLang, Status)); > + } else { > + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_BOOLEAN) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not boolean type\n", > __FUNCTION__, Schema, Version, ConfigureLang)); > + return EFI_DEVICE_ERROR; > + } > + > + if (RedfishValue.Value.Boolean !=3D FeatureValue) { > + // > + // Apply settings from redfish > + // > + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s from %a to %a\n", > __FUNCTION__, Schema, Version, ConfigureLang, > (RedfishValue.Value.Boolean ? "True" : "False"), (FeatureValue ? "True" : > "False"))); > + > + RedfishValue.Value.Boolean =3D FeatureValue; > + > + Status =3D RedfishPlatformConfigSetValue (Schema, Version, > ConfigureLang, RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, apply %s to %a failed: %r\n", > __FUNCTION__, ConfigureLang, (FeatureValue ? "True" : "False"), Status)); > + } > + } else { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is: %a\n", > __FUNCTION__, Schema, Version, ConfigureLang, > (RedfishValue.Value.Boolean ? "True" : "False"), Status)); > + } > + } > + > + return Status; > +} > + > +/** > + > + Read redfish resource by given resource path. > + > + @param[in] Service Redfish srvice instacne to make query. > + @param[in] ResourcePath Target resource path. > + @param[out] Response HTTP response from redfish service. > + > + @retval EFI_SUCCESS Resrouce is returned successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetResourceByPath ( > + IN REDFISH_SERVICE *Service, > + IN CHAR8 *ResourcePath, > + OUT REDFISH_RESPONSE *Response > + ) > +{ > + EFI_STATUS Status; > + > + if ((Service =3D=3D NULL) || (Response =3D=3D NULL) || IS_EMPTY_STRING > (ResourcePath)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Get resource from redfish service. > + // > + Status =3D RedfishGetByService ( > + Service, > + ResourcePath, > + Response > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %a failed: %r\n", > __FUNCTION__, ResourcePath, Status)); > + if (Response->Payload !=3D NULL) { > + RedfishDumpPayload (Response->Payload); > + RedfishFreeResponse ( > + NULL, > + 0, > + NULL, > + Response->Payload > + ); > + Response->Payload =3D NULL; > + } > + > + return Status; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + > + Find array index from given configure language string. > + > + @param[in] ConfigureLang Configure language string to parse. > + @param[out] UnifiedConfigureLang The configure language in array. > + @param[out] Index The array index number. > + > + @retval EFI_SUCCESS Index is found. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetArrayIndexFromArrayTypeConfigureLang ( > + IN CHAR16 *ConfigureLang, > + OUT CHAR16 **UnifiedConfigureLang, > + OUT UINTN *Index > + ) > +{ > + CHAR16 *TmpConfigureLang; > + CHAR16 *IndexString; > + CHAR16 *TmpString; > + > + if ((ConfigureLang =3D=3D NULL) || (UnifiedConfigureLang =3D=3D NULL) = || (Index > =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + TmpConfigureLang =3D AllocateCopyPool (StrSize (ConfigureLang), > ConfigureLang); > + if (TmpConfigureLang =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + // > + // looking for index signature "{"" > + // > + IndexString =3D StrStr (TmpConfigureLang, > BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_START_SIGNATURE); > + if (IndexString =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + // > + // Skip "{" > + // > + TmpString =3D IndexString + StrLen > (BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_START_SIGNATURE); > + > + // > + // Looking for "}" > + // > + TmpString =3D StrStr (TmpString, > BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_END_SIGNATURE); > + if (TmpString =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + // > + // Append '\0' for converting decimal string to integer. > + // > + TmpString[0] =3D '\0'; > + > + // > + // Convert decimal string to integer > + // > + *Index =3D StrDecimalToUintn (IndexString + StrLen > (BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_START_SIGNATURE)); > + > + // > + // Resotre the '}' character and remove rest of string. > + // > + TmpString[0] =3D L'}'; > + TmpString[1] =3D '\0'; > + > + *UnifiedConfigureLang =3D TmpConfigureLang; > + > + return EFI_SUCCESS; > +} > + > +/** > + > + Search HII database with given Configure Language pattern. Data is > handled and > + returned in array. > + > + @param[in] Schema The schema to search. > + @param[in] Version The schema version. > + @param[in] Pattern Configure Language pattern to se= arch. > + @param[out] UnifiedConfigureLangList The data returned by HII databas= e. > + > + @retval EFI_SUCCESS Data is found and returned. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +RedfishFeatureGetUnifiedArrayTypeConfigureLang ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING Pattern, OPTIONAL > + OUT REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST > *UnifiedConfigureLangList > + ) > +{ > + EFI_STATUS Status; > + EFI_STRING *ConfigureLangList; > + UINTN Count; > + UINTN Index; > + UINTN Index2; > + UINTN ArrayIndex; > + EFI_STRING UnifiedConfigureLang; > + BOOLEAN Duplicated; > + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG > UnifiedConfigureLangPool[BIOS_CONFIG_TO_REDFISH_REDPATH_POOL_SIZ > E]; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > (UnifiedConfigureLangList =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + UnifiedConfigureLangList->Count =3D 0; > + UnifiedConfigureLangList->List =3D NULL; > + ZeroMem (UnifiedConfigureLangPool, sizeof (UnifiedConfigureLangPool)); > + > + Status =3D RedfishPlatformConfigGetConfigureLang (Schema, Version, > Pattern, &ConfigureLangList, &Count); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, RedfishFeatureGetConfigureLangRegex > failed: %r\n", __FUNCTION__, Status)); > + return Status; > + } > + > + if (Count =3D=3D 0) { > + return EFI_NOT_FOUND; > + } > + > + for (Index =3D 0; Index < Count; Index++) { > + Status =3D GetArrayIndexFromArrayTypeConfigureLang > (ConfigureLangList[Index], &UnifiedConfigureLang, &ArrayIndex); > + if (EFI_ERROR (Status)) { > + ASSERT (FALSE); > + continue; > + } > + > + // > + // Check if this configure language is duplicated. > + // > + Duplicated =3D FALSE; > + for (Index2 =3D 0; Index2 < > BIOS_CONFIG_TO_REDFISH_REDPATH_POOL_SIZE; Index2++) { > + if (UnifiedConfigureLangPool[Index2].ConfigureLang =3D=3D NULL) { > + break; > + } > + > + if (StrCmp (UnifiedConfigureLangPool[Index2].ConfigureLang, > UnifiedConfigureLang) =3D=3D 0) { > + Duplicated =3D TRUE; > + break; > + } > + } > + > + if (Duplicated) { > + FreePool (UnifiedConfigureLang); > + continue; > + } > + > + if (UnifiedConfigureLangList->Count >=3D > BIOS_CONFIG_TO_REDFISH_REDPATH_POOL_SIZE) { > + FreePool (UnifiedConfigureLang); > + Status =3D EFI_BUFFER_TOO_SMALL; > + break; > + } > + > + // > + // New configure language. Keep it in Pool > + // > + > + UnifiedConfigureLangPool[UnifiedConfigureLangList- > >Count].ConfigureLang =3D UnifiedConfigureLang; > + UnifiedConfigureLangPool[UnifiedConfigureLangList->Count].Index = =3D > ArrayIndex; > + ++UnifiedConfigureLangList->Count; > + } > + > + FreePool (ConfigureLangList); > + > + // > + // Prepare the result to caller. > + // > + UnifiedConfigureLangList->List =3D AllocateCopyPool (sizeof > (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * > UnifiedConfigureLangList->Count, UnifiedConfigureLangPool); > + > + return Status; > +} > + > +/** > + > + Create HTTP payload and send them to redfish service with PATCH method= . > + > + @param[in] Service Redfish service. > + @param[in] TargetPayload Target payload > + @param[in] Json Data in JSON format. > + @param[out] Etag Returned ETAG string from Redfish service. > + > + @retval EFI_SUCCESS Data is sent to redfish service successful= ly. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +CreatePayloadToPatchResource ( > + IN REDFISH_SERVICE *Service, > + IN REDFISH_PAYLOAD *TargetPayload, > + IN CHAR8 *Json, > + OUT CHAR8 **Etag > + ) > +{ > + REDFISH_PAYLOAD Payload; > + EDKII_JSON_VALUE ResourceJsonValue; > + REDFISH_RESPONSE PostResponse; > + EFI_STATUS Status; > + UINTN Index; > + EDKII_JSON_VALUE JsonValue; > + EDKII_JSON_VALUE OdataIdValue; > + CHAR8 *OdataIdString; > + > + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_S= TRING > (Json) || (Etag =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ResourceJsonValue =3D JsonLoadString (Json, 0, NULL); > + Payload =3D RedfishCreatePayload (ResourceJsonValue, Service= ); > + if (Payload =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from > JSON value!\n", __FUNCTION__, __LINE__)); > + Status =3D EFI_DEVICE_ERROR; > + goto EXIT_FREE_JSON_VALUE; > + } > + > + ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); > + Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PostRespons= e); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a:%d Failed to PATCH payload to Redfish > service.\n", __FUNCTION__, __LINE__)); > + goto EXIT_FREE_JSON_VALUE; > + } > + > + // > + // Keep etag. > + // > + *Etag =3D NULL; > + if (*PostResponse.StatusCode =3D=3D HTTP_STATUS_200_OK) { > + if (PostResponse.HeaderCount !=3D 0) { > + for (Index =3D 0; Index < PostResponse.HeaderCount; Index++) { > + if (AsciiStrnCmp (PostResponse.Headers[Index].FieldName, "ETag",= 4) > =3D=3D 0) { > + *Etag =3D AllocateCopyPool (AsciiStrSize > (PostResponse.Headers[Index].FieldValue), > PostResponse.Headers[Index].FieldValue); > + } > + } > + } else if (PostResponse.Payload !=3D NULL) { > + // > + // No header is returned. Search payload for location. > + // > + JsonValue =3D RedfishJsonInPayload (PostResponse.Payload); > + if (JsonValue !=3D NULL) { > + OdataIdValue =3D JsonObjectGetValue (JsonValueGetObject (JsonVal= ue), > "@odata.etag"); > + if (OdataIdValue !=3D NULL) { > + OdataIdString =3D (CHAR8 *)JsonValueGetAsciiString (OdataIdVal= ue); > + if (OdataIdString !=3D NULL) { > + *Etag =3D AllocateCopyPool (AsciiStrSize (OdataIdString), Od= ataIdString); > + } > + } > + } > + } > + } > + > + RedfishFreeResponse ( > + PostResponse.StatusCode, > + PostResponse.HeaderCount, > + PostResponse.Headers, > + PostResponse.Payload > + ); > + > +EXIT_FREE_JSON_VALUE: > + if (Payload !=3D NULL) { > + RedfishCleanupPayload (Payload); > + } > + > + JsonValueFree (ResourceJsonValue); > + > + return Status; > +} > + > +/** > + > + Create HTTP payload and send them to redfish service with POST method. > + > + @param[in] Service Redfish service. > + @param[in] TargetPayload Target payload > + @param[in] Json Data in JSON format. > + @param[out] Location Returned location string from Redfish serv= ice. > + @param[out] Etag Returned ETAG string from Redfish service. > + > + @retval EFI_SUCCESS Data is sent to redfish service successful= ly. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +CreatePayloadToPostResource ( > + IN REDFISH_SERVICE *Service, > + IN REDFISH_PAYLOAD *TargetPayload, > + IN CHAR8 *Json, > + OUT CHAR8 **Location, > + OUT CHAR8 **Etag > + ) > +{ > + REDFISH_PAYLOAD Payload; > + EDKII_JSON_VALUE ResourceJsonValue; > + REDFISH_RESPONSE PostResponse; > + EFI_STATUS Status; > + UINTN Index; > + EDKII_JSON_VALUE JsonValue; > + EDKII_JSON_VALUE OdataIdValue; > + CHAR8 *OdataIdString; > + > + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_S= TRING > (Json) || (Location =3D=3D NULL) || (Etag =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ResourceJsonValue =3D JsonLoadString (Json, 0, NULL); > + Payload =3D RedfishCreatePayload (ResourceJsonValue, Service= ); > + if (Payload =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from > JSON value!\n", __FUNCTION__, __LINE__)); > + Status =3D EFI_DEVICE_ERROR; > + goto EXIT_FREE_JSON_VALUE; > + } > + > + ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); > + Status =3D RedfishPostToPayload (TargetPayload, Payload, &PostResponse= ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a:%d Failed to POST Attribute Registry to > Redfish service.\n", __FUNCTION__, __LINE__)); > + goto EXIT_FREE_JSON_VALUE; > + } > + > + // > + // per Redfish spec. the URL of new eresource will be returned in > "Location" header. > + // > + *Location =3D NULL; > + *Etag =3D NULL; > + if (*PostResponse.StatusCode =3D=3D HTTP_STATUS_200_OK) { > + if (PostResponse.HeaderCount !=3D 0) { > + for (Index =3D 0; Index < PostResponse.HeaderCount; Index++) { > + if (AsciiStrnCmp (PostResponse.Headers[Index].FieldName, "Locati= on", > 8) =3D=3D 0) { > + *Location =3D AllocateCopyPool (AsciiStrSize > (PostResponse.Headers[Index].FieldValue), > PostResponse.Headers[Index].FieldValue); > + } else if (AsciiStrnCmp (PostResponse.Headers[Index].FieldName, > "ETag", 4) =3D=3D 0) { > + *Etag =3D AllocateCopyPool (AsciiStrSize > (PostResponse.Headers[Index].FieldValue), > PostResponse.Headers[Index].FieldValue); > + } > + } > + } else if (PostResponse.Payload !=3D NULL) { > + // > + // No header is returned. Search payload for location. > + // > + JsonValue =3D RedfishJsonInPayload (PostResponse.Payload); > + if (JsonValue !=3D NULL) { > + OdataIdValue =3D JsonObjectGetValue (JsonValueGetObject (JsonVal= ue), > "@odata.id"); > + if (OdataIdValue !=3D NULL) { > + OdataIdString =3D (CHAR8 *)JsonValueGetAsciiString (OdataIdVal= ue); > + if (OdataIdString !=3D NULL) { > + *Location =3D AllocateCopyPool (AsciiStrSize (OdataIdString)= , > OdataIdString); > + } > + } > + > + OdataIdValue =3D JsonObjectGetValue (JsonValueGetObject (JsonVal= ue), > "@odata.etag"); > + if (OdataIdValue !=3D NULL) { > + OdataIdString =3D (CHAR8 *)JsonValueGetAsciiString (OdataIdVal= ue); > + if (OdataIdString !=3D NULL) { > + *Etag =3D AllocateCopyPool (AsciiStrSize (OdataIdString), Od= ataIdString); > + } > + } > + } > + } > + } > + > + // > + // This is not expected as service does not follow spec. > + // > + if (*Location =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + } > + > + RedfishFreeResponse ( > + PostResponse.StatusCode, > + PostResponse.HeaderCount, > + PostResponse.Headers, > + PostResponse.Payload > + ); > + > + RedfishCleanupPayload (Payload); > + > +EXIT_FREE_JSON_VALUE: > + JsonValueFree (JsonValue); > + JsonValueFree (ResourceJsonValue); > + > + return Status; > +} > + > +/** > + > + Find Redfish Resource Config Protocol that supports given schema and > version. > + > + @param[in] Schema Schema name. > + @param[in] Major Schema version major number. > + @param[in] Minor Schema version minor number. > + @param[in] Errata Schema version errata number. > + > + @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to > protocol > + @retval NULL No protocol fo= und. > + > +**/ > +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * > +GetRedfishResourceConfigProtocol ( > + IN CHAR8 *Schema, > + IN CHAR8 *Major, > + IN CHAR8 *Minor, > + IN CHAR8 *Errata > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE *HandleBuffer; > + UINTN NumberOfHandles; > + UINTN Index; > + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *Protocol; > + REDFISH_SCHEMA_INFO SchemaInfo; > + BOOLEAN Found; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Major) || > IS_EMPTY_STRING (Minor) || IS_EMPTY_STRING (Errata)) { > + return NULL; > + } > + > + Status =3D gBS->LocateHandleBuffer ( > + ByProtocol, > + &gEdkIIRedfishResourceConfigProtocolGuid, > + NULL, > + &NumberOfHandles, > + &HandleBuffer > + ); > + if (EFI_ERROR (Status)) { > + return NULL; > + } > + > + Found =3D FALSE; > + > + for (Index =3D 0; Index < NumberOfHandles; Index++) { > + Status =3D gBS->HandleProtocol ( > + HandleBuffer[Index], > + &gEdkIIRedfishResourceConfigProtocolGuid, > + (VOID **)&Protocol > + ); > + if (EFI_ERROR (Status)) { > + continue; > + } > + > + Status =3D Protocol->GetInfo (Protocol, &SchemaInfo); > + if (EFI_ERROR (Status)) { > + continue; > + } > + > + if ((AsciiStrCmp (Schema, SchemaInfo.Schema) =3D=3D 0) && > + (AsciiStrCmp (Major, SchemaInfo.Major) =3D=3D 0) && > + (AsciiStrCmp (Minor, SchemaInfo.Minor) =3D=3D 0) && > + (AsciiStrCmp (Errata, SchemaInfo.Errata) =3D=3D 0)) > + { > + Found =3D TRUE; > + break; > + } > + } > + > + FreePool (HandleBuffer); > + > + return (Found ? Protocol : NULL); > +} > + > +/** > + > + Get supported schema list by given specify schema name. > + > + @param[in] Schema Schema type name. > + @param[out] SchemaInfo Returned schema information. > + > + @retval EFI_SUCCESS Schema information is returned success= fully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetSupportedSchemaVersion ( > + IN CHAR8 *Schema, > + OUT REDFISH_SCHEMA_INFO *SchemaInfo > + ) > +{ > + EFI_STATUS Status; > + CHAR8 *SupportSchema; > + CHAR8 *SchemaName; > + UINTN Index; > + UINTN Index2; > + BOOLEAN Found; > + > + if (IS_EMPTY_STRING (Schema) || (SchemaInfo =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D RedfishPlatformConfigGetSupportedSchema (NULL, > &SupportSchema); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + DEBUG ((DEBUG_INFO, "Supported schema: %a\n", SupportSchema)); > + > + Index =3D 0; > + Found =3D FALSE; > + SchemaName =3D SupportSchema; > + while (TRUE) { > + if ((SupportSchema[Index] =3D=3D ';') || (SupportSchema[Index] =3D= =3D '\0')) { > + if (AsciiStrnCmp (&SchemaName[SCHEMA_NAME_PREFIX_OFFSET], > Schema, AsciiStrLen (Schema)) =3D=3D 0) { > + Found =3D TRUE; > + SupportSchema[Index] =3D '\0'; > + break; > + } > + > + SchemaName =3D &SupportSchema[Index + 1]; > + } > + > + if (SupportSchema[Index] =3D=3D '\0') { > + break; > + } > + > + ++Index; > + } > + > + if (Found) { > + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, > Schema); > + > + // > + // forward to '.' > + // > + Index =3D 0; > + while (SchemaName[Index] !=3D '\0' && SchemaName[Index] !=3D '.') { > + ++Index; > + } > + > + ASSERT (SchemaName[Index] !=3D '\0'); > + > + // > + // Skip '.' and 'v' > + // > + Index +=3D 2; > + > + // > + // forward to '_' > + // > + Index2 =3D Index; > + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') = { > + ++Index2; > + } > + > + ASSERT (SchemaName[Index2] !=3D '\0'); > + > + AsciiStrnCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, > &SchemaName[Index], (Index2 - Index)); > + Index =3D Index2; > + > + // > + // Skip '_' > + // > + ++Index; > + > + // > + // forward to '_' > + // > + Index2 =3D Index; > + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') = { > + ++Index2; > + } > + > + ASSERT (SchemaName[Index2] !=3D '\0'); > + > + AsciiStrnCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, > &SchemaName[Index], (Index2 - Index)); > + Index =3D Index2; > + > + // > + // Skip '_' > + // > + ++Index; > + > + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, > &SchemaName[Index]); > + } > + > + FreePool (SupportSchema); > + > + return (Found ? EFI_SUCCESS : EFI_NOT_FOUND); > +} > + > +/** > + > + Return system root path. This is dummy function now. > + > + @retval NULL Can not find system root path. > + @retval Other System root path is returned. > + > +**/ > +CHAR8 * > +RedfishGetSystemRootPath ( > + VOID > + ) > +{ > + return AllocateCopyPool (AsciiStrSize (REDFISH_SYSTEM_ROOT_PATH), > REDFISH_SYSTEM_ROOT_PATH); > +} > + > +/** > + > + Get schema information by given protocol and service instance. > + > + @param[in] RedfishService Pointer to Redfish service instance. > + @param[in] JsonStructProtocol Json Structure protocol instance. > + @param[in] Uri Target URI. > + @param[out] SchemaInfo Returned schema information. > + > + @retval EFI_SUCCESS Schema information is returned success= fully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +GetRedfishSchemaInfo ( > + IN REDFISH_SERVICE *RedfishService, > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, > + IN CHAR8 *Uri, > + OUT REDFISH_SCHEMA_INFO *SchemaInfo > + ) > +{ > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + REDFISH_PAYLOAD Payload; > + CHAR8 *JsonText; > + EFI_REST_JSON_STRUCTURE_HEADER *Header; > + > + if ((RedfishService =3D=3D NULL) || (JsonStructProtocol =3D=3D NULL) |= | > IS_EMPTY_STRING (Uri) || (SchemaInfo =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D GetResourceByPath (RedfishService, Uri, &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %a %r", > __FUNCTION__, Uri, Status)); > + return Status; > + } > + > + Payload =3D Response.Payload; > + ASSERT (Payload !=3D NULL); > + > + JsonText =3D JsonDumpString (RedfishJsonInPayload (Payload), > EDKII_JSON_COMPACT); > + ASSERT (JsonText !=3D NULL); > + > + // > + // Convert JSON text to C structure. > + // > + Status =3D JsonStructProtocol->ToStructure ( > + JsonStructProtocol, > + NULL, > + JsonText, > + &Header > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", > __FUNCTION__, Status)); > + return Status; > + } > + > + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, > Header->JsonRsrcIdentifier.NameSpace.ResourceTypeName); > + AsciiStrCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, > Header->JsonRsrcIdentifier.NameSpace.MajorVersion); > + AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, > Header->JsonRsrcIdentifier.NameSpace.MinorVersion); > + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, > Header->JsonRsrcIdentifier.NameSpace.ErrataVersion); > + > + // > + // Release resource. > + // > + JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header); > + FreePool (JsonText); > + RedfishFreeResponse (Response.StatusCode, Response.HeaderCount, > Response.Headers, Response.Payload); > + > + return EFI_SUCCESS; > +} > + > +/** > + > + Get the property name by given Configure Langauge. > + > + @param[in] ConfigureLang Configure Language string. > + > + @retval EFI_STRING Pointer to property name. > + @retval NULL There is error. > + > +**/ > +EFI_STRING > +GetPropertyFromConfigureLang ( > + IN EFI_STRING ConfigureLang > + ) > +{ > + EFI_STRING Property; > + UINTN Index; > + > + if (ConfigureLang =3D=3D NULL) { > + return NULL; > + } > + > + Index =3D 0; > + Property =3D ConfigureLang; > + > + while (ConfigureLang[Index] !=3D '\0') { > + if (ConfigureLang[Index] =3D=3D L'/') { > + Property =3D &ConfigureLang[Index]; > + } > + > + ++Index; > + } > + > + ++Property; > + > + return Property; > +} > + > +/** > + > + Get the property value in string type. > + > + @param[in] Schema Schema of this property. > + @param[in] Version Schema version. > + @param[in] PropertyName Property name. > + @param[in] ConfigureLang Configure Language of this property. > + > + @retval CHAR8* Pointer to the CHAR8 buffer. > + @retval NULL There is error. > + > +**/ > +CHAR8 * > +GetPropertyStringValue ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING PropertyName, > + IN EFI_STRING ConfigureLang > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_VALUE RedfishValue; > + EFI_STRING ConfigureLangBuffer; > + UINTN BufferSize; > + CHAR8 *AsciiStringValue; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > IS_EMPTY_STRING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { > + return NULL; > + } > + > + // > + // Configure Language buffer. > + // > + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; > + ConfigureLangBuffer =3D AllocatePool (BufferSize); > + if (ConfigureLangBuffer =3D=3D NULL) { > + return NULL; > + } > + > + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLan= g, > PropertyName); > + Status =3D RedfishPlatformConfigGetValue (Schema, Version, > ConfigureLangBuffer, &RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: > %r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); > + return NULL; > + } > + > + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_STRING) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string type\n", > __FUNCTION__, Schema, Version, ConfigureLang)); > + return NULL; > + } > + > + AsciiStringValue =3D AllocateCopyPool (AsciiStrSize > (RedfishValue.Value.Buffer), RedfishValue.Value.Buffer); > + ASSERT (AsciiStringValue !=3D NULL); > + > + return AsciiStringValue; > +} > + > +/** > + > + Get the property value in numeric type. > + > + @param[in] Schema Schema of this property. > + @param[in] Version Schema version. > + @param[in] PropertyName Property name. > + @param[in] ConfigureLang Configure Language of this property. > + > + @retval INT64* Pointer to the INT64 value. > + @retval NULL There is error. > + > +**/ > +INT64 * > +GetPropertyNumericValue ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING PropertyName, > + IN EFI_STRING ConfigureLang > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_VALUE RedfishValue; > + EFI_STRING ConfigureLangBuffer; > + UINTN BufferSize; > + INT64 *ResultValue; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > IS_EMPTY_STRING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { > + return NULL; > + } > + > + // > + // Configure Language buffer. > + // > + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; > + ConfigureLangBuffer =3D AllocatePool (BufferSize); > + if (ConfigureLangBuffer =3D=3D NULL) { > + return NULL; > + } > + > + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLan= g, > PropertyName); > + Status =3D RedfishPlatformConfigGetValue (Schema, Version, > ConfigureLangBuffer, &RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: > %r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); > + return NULL; > + } > + > + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_INTEGER) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not numeric type\n", > __FUNCTION__, Schema, Version, ConfigureLang)); > + return NULL; > + } > + > + ResultValue =3D AllocatePool (sizeof (INT64)); > + ASSERT (ResultValue !=3D NULL); > + if (ResultValue =3D=3D NULL) { > + return NULL; > + } > + > + *ResultValue =3D RedfishValue.Value.Integer; > + > + return ResultValue; > +} > + > +/** > + > + Get the property value in Boolean type. > + > + @param[in] Schema Schema of this property. > + @param[in] Version Schema version. > + @param[in] PropertyName Property name. > + @param[in] ConfigureLang Configure Language of this property. > + > + @retval BOOLEAN Boolean value returned by this property. > + > +**/ > +BOOLEAN * > +GetPropertyBooleanValue ( > + IN CHAR8 *Schema, > + IN CHAR8 *Version, > + IN EFI_STRING PropertyName, > + IN EFI_STRING ConfigureLang > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_VALUE RedfishValue; > + EFI_STRING ConfigureLangBuffer; > + UINTN BufferSize; > + BOOLEAN *ResultValue; > + > + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || > IS_EMPTY_STRING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { > + return NULL; > + } > + > + // > + // Configure Language buffer. > + // > + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; > + ConfigureLangBuffer =3D AllocatePool (BufferSize); > + if (ConfigureLangBuffer =3D=3D NULL) { > + return NULL; > + } > + > + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLan= g, > PropertyName); > + Status =3D RedfishPlatformConfigGetValue (Schema, Version, > ConfigureLangBuffer, &RedfishValue); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: > %r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); > + return NULL; > + } > + > + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_BOOLEAN) { > + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not boolean type\n", > __FUNCTION__, Schema, Version, ConfigureLang)); > + return NULL; > + } > + > + ResultValue =3D AllocatePool (sizeof (BOOLEAN)); > + ASSERT (ResultValue !=3D NULL); > + if (ResultValue =3D=3D NULL) { > + return NULL; > + } > + > + *ResultValue =3D RedfishValue.Value.Boolean; > + > + return ResultValue; > +} > + > +/** > + > + Check and see if we need to do provisioning for this property. > + > + @param[in] PropertyBuffer Pointer to property instance. > + @param[in] ProvisionMode TRUE if we are in provision mode. FALSE > otherwise. > + > + @retval TRUE Provision is required. > + @retval FALSE Provision is not required. > + > +**/ > +BOOLEAN > +PropertyChecker ( > + IN VOID *PropertyBuffer, > + IN BOOLEAN ProvisionMode > + ) > +{ > + if (ProvisionMode && (PropertyBuffer =3D=3D NULL)) { > + return TRUE; > + } > + > + if (!ProvisionMode && (PropertyBuffer !=3D NULL)) { > + return TRUE; > + } > + > + return FALSE; > +} > + > +/** > + > + Check and see if we need to do provisioning for this two properties. > + > + @param[in] PropertyBuffer1 Pointer to property instance 1. > + @param[in] PropertyBuffer2 Pointer to property instance 2. > + @param[in] ProvisionMode TRUE if we are in provision mode. FALSE > otherwise. > + > + @retval TRUE Provision is required. > + @retval FALSE Provision is not required. > + > +**/ > +BOOLEAN > +PropertyChecker2Parm ( > + IN VOID *PropertyBuffer1, > + IN VOID *PropertyBuffer2, > + IN BOOLEAN ProvisionMode > + ) > +{ > + if (ProvisionMode && ((PropertyBuffer1 =3D=3D NULL) || (PropertyBuffer= 2 =3D=3D > NULL))) { > + return TRUE; > + } > + > + if (!ProvisionMode && (PropertyBuffer1 !=3D NULL) && (PropertyBuffer2 = !=3D > NULL)) { > + return TRUE; > + } > + > + return FALSE; > +} > + > +/** > + > + Install Boot Maintenance Manager Menu driver. > + > + @param[in] ImageHandle The image handle. > + @param[in] SystemTable The system table. > + > + @retval EFI_SUCEESS Install Boot manager menu success. > + @retval Other Return error status. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishFeatureUtilityLibConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + return EFI_SUCCESS; > +} > + > +/** > + Unloads the application and its installed protocol. > + > + @param[in] ImageHandle Handle that identifies the image to be > unloaded. > + @param[in] SystemTable The system table. > + > + @retval EFI_SUCCESS The image has been unloaded. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishFeatureUtilityLibDestructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + return EFI_SUCCESS; > +} > -- > 2.17.1