From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.86]) by mx.groups.io with SMTP id smtpd.web10.16027.1670422222035800937 for ; Wed, 07 Dec 2022 06:10:22 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=puXToczG; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.92.86, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MiZJzZoyhITDTcKJ0hs2D+i3PBO1ERXsoeCy8bCZq5HvtnRwywIzTswCrJ9XNAZC1mPTPHirTx98Y4/sOtYkRdpm38wlkMgzQaZi5OFQQb5wYtR44eLLZfMOQYz5Is/jr/0GALLfwqOrbtCP1m27N8utOX4OwxqI08pO0bVPOZHTPYG+vw04Q3N0gMmQfXO8dzJ5kVcGpuFweFaPG8EaPmLEIZg7THbGiNYOqKO3n8AbXfJU/Jf1cr9Fa6Am934i0HuYEPISnKRBeQkHgJvMsL0SG4BzvyXS6rhNNLneaZh4HeALKIbwgOuZJDL0r54oDPkcEIx68Pzn4+p/6hOw7A== 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=WxED8ozbsU9KtVFYHJXRF01sL6fdqfg1PmlGO5J4mzg=; b=Q6VJzK+6ehFIUbRC+H2fGIwKhWb9YBVVGmcqvyCJusWW3fkwli+qMc6WVwflVN9wXWyndga0s7dqCple9d7JnPHSnefg+6xOSgHo9fDGP96sRhpW61GLoYo/x05Tddb53if9lHW7MHJS0X7fsAb5DRp6+79yGMpbDocMWpQHwpOPBjSLKc20SbsHEPdABVHgqDhFycjOq02bFfVlfKi2vFGFlW/TXgbsS3J/n1S01+dWka1uUa0D/I2+RpZBFB/wOHjGFyWa5kG03jJvJPP0K4M6xXmCWUNbMzd/Mxu6UwpaYjQvi94XqbO5twOZapGgkXC0uNT/vlZL4IcOGUjHKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WxED8ozbsU9KtVFYHJXRF01sL6fdqfg1PmlGO5J4mzg=; b=puXToczG6+TpLfWudi91cUAVPXQrfBQ4FiKNcBGXnXMoFNvadBnxhHuM0CaDxVqqAYiGYQ2Ib3XqC829aEjCCQqGBfXvlOX/drbOmnVFGE9WlrF7Qb2PGe/5kS82U5Cj+YYVWH4WOYbsVVGWT50QGpb+M3ghgWuH0Zf5hBg8HiqbqSKb4Uw20FhnYGgao1hPZ4DpwPro0hgeGKHkMzjd1sS21KNxpeL4o548lgY0ZjasGTpkacLyitwxog7hb01CNqMFfm1AYcdGHldc9rKpR6n4AwzVC+58RRaVzJNfYFKJ5kd1m2bofAF1tWdtX1xXIlkzj8agPvrqYO3oAnyrow== Received: from MW4PR03CA0348.namprd03.prod.outlook.com (2603:10b6:303:dc::23) by BL0PR12MB4915.namprd12.prod.outlook.com (2603:10b6:208:1c9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 14:10:18 +0000 Received: from CO1NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::9b) by MW4PR03CA0348.outlook.office365.com (2603:10b6:303:dc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Wed, 7 Dec 2022 14:10:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT028.mail.protection.outlook.com (10.13.175.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.14 via Frontend Transport; Wed, 7 Dec 2022 14:10:17 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 7 Dec 2022 06:10:08 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 7 Dec 2022 06:10:07 -0800 Received: from NV-CL38DL3.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Wed, 7 Dec 2022 06:10:06 -0800 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-staging][PATCH 2/3] edk2-staging/RedfishPkg: Introduce new interfaces to Redfish protocol Date: Wed, 7 Dec 2022 22:10:07 +0800 Message-ID: <20221207141007.170-1-nicklew@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Return-Path: nicklew@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT028:EE_|BL0PR12MB4915:EE_ X-MS-Office365-Filtering-Correlation-Id: e482ce5c-539a-4c52-2035-08dad85cc4c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +aodqka3xkWACIxzTMVuyafFrHOheJIvPmrN+FRN/WrIngbitdmhGbG+0YJkKGIWeKDLpuwlzwLat3LDXuXREmGAcRfLvQ4wytJCAicUHvquXQ4K72WiNIIeBrS+q92995VKSxbG/ia2Vy5I5dAWz0gpiolezqnl547bweXVztluXma6wVJ6Uj4BLhxlIVjbFf0v16jOW5Tpg6+fclAtivMT4M9kx9GegXeUmPQHqzfJx9YWJXkPYm2VMomzrmnbgs0/GYhA9jHZWeNjRhevhzoq1aeMeVU1XUnwTm2APflH1u0ulR/KIruO1iKm03azID8EYA08Cxrb3Nwp4SHF2T8OWe/axiLMCXge8n9sk4MLIHgWn4WlnxYVzO2es8BiQ82rxOjkfSS4suAySVT0pJFYgvM/ds+HlsJ9urk+Hih7u5LEHOK8c0xi6Qrw5JGS1MKyfWg30XF0xHTIRPPD9rB+J1H2S6z5S8HNE33Wbty0pNf4tKnVw7LKbENXlssgHbSt23drmQeuxoeYygY3iZb9JKhjjVgHOcVzAK0bVig5scIqzavJAjFMwwGswaudGrChlK4p//IlfBLMeSTD294sskrP286OEftjuswX//Rgbz/SqlHNMjBhzhNIcWR/ye371yAWRtPCqKx18sNlLVc93CQHJdVf1Kx/7d8zBgndEHHx1Vphj3xULT+jmw5up+URH9/ivqeok8BXH0kY6Q== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(36756003)(66899015)(54906003)(356005)(2906002)(7636003)(86362001)(8936002)(70586007)(40460700003)(5660300002)(4326008)(83380400001)(36860700001)(30864003)(478600001)(70206006)(316002)(6916009)(19627235002)(2616005)(82740400003)(40480700001)(82310400005)(1076003)(47076005)(8676002)(107886003)(41300700001)(336012)(186003)(426003)(7696005)(26005)(579004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 14:10:17.5384 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e482ce5c-539a-4c52-2035-08dad85cc4c7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4915 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Add two new iterfaces to Redfish Platform Config Protocol. GetAttribute() return attribute details and GetDefaultValue() get default value of attribute. These two interfaces are used to generate BIOS Attribute Registry Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../Protocol/EdkIIRedfishPlatformConfig.h | 105 +++ .../RedfishPlatformConfigDxe.c | 625 ++++++++++++++---- .../RedfishPlatformConfigDxe.h | 2 + .../RedfishPlatformConfigImpl.c | 55 +- .../RedfishPlatformConfigImpl.h | 44 +- 5 files changed, 705 insertions(+), 126 deletions(-) diff --git a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h b/Red= fishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h index bbbab90b03..9be83b5e0b 100644 --- a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h +++ b/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h @@ -2,6 +2,7 @@ This file defines the EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL interface. =20 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -38,6 +39,18 @@ typedef enum { REDFISH_VALUE_TYPE_MAX } EDKII_REDFISH_VALUE_TYPES; =20 +/** + Definition of EDKII_REDFISH_ATTRIBUTE_TYPES + **/ +typedef enum { + REDFISH_ATTRIBUTE_TYPE_UNKNOWN =3D 0, + REDFISH_ATTRIBUTE_TYPE_ENUMERATION, + REDFISH_ATTRIBUTE_TYPE_STRING, + REDFISH_ATTRIBUTE_TYPE_INTEGER, + REDFISH_ATTRIBUTE_TYPE_BOOLEAN, + REDFISH_ATTRIBUTE_TYPE_PASSWORD +} EDKII_REDFISH_ATTRIBUTE_TYPES; + /** Definition of EDKII_REDFISH_VALUE **/ @@ -47,6 +60,41 @@ typedef struct { UINTN ArrayCount; } EDKII_REDFISH_VALUE; =20 +/** + Definition of EDKII_REDFISH_ATTRIBUTE_VALUE + **/ +typedef struct { + CHAR8 *ValueName; + CHAR8 *ValueDisplayName; +} EDKII_REDFISH_ATTRIBUTE_VALUE; + +/** + Definition of EDKII_REDFISH_POSSIBLE_VALUES + **/ +typedef struct { + UINTN ValueCount; + EDKII_REDFISH_ATTRIBUTE_VALUE *ValueArray; +} EDKII_REDFISH_POSSIBLE_VALUES; + +/** + Definition of EDKII_REDFISH_ATTRIBUTE + **/ +typedef struct { + CHAR8 *AttributeName; + CHAR8 *DisplayName; + CHAR8 *HelpText; + CHAR8 *MenuPath; + EDKII_REDFISH_ATTRIBUTE_TYPES Type; + BOOLEAN ResetRequired; + BOOLEAN ReadOnly; + UINT64 NumMaximum; + UINT64 NumMinimum; + UINT64 NumStep; + UINT8 StrMaxSize; + UINT8 StrMinSize; + EDKII_REDFISH_POSSIBLE_VALUES Values; +} EDKII_REDFISH_ATTRIBUTE; + /** Get Redfish value with the given Schema and Configure Language. =20 @@ -70,6 +118,37 @@ EFI_STATUS OUT EDKII_REDFISH_VALUE *Value ); =20 +// +// Default class standard +// +#define EDKII_REDFISH_DEFAULT_CLASS_STANDARD EFI_HII_DEFAULT_CLASS_STANDA= RD + +/** + Get Redfish default value with the given Schema and Configure Language. + + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance. + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[in] DefaultClass The UEFI defined default class. + Please refer to UEFI spec. 33.2.5.8 "de= faults" for details. + @param[out] Value The returned value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_DEFAULT_VALUE)( + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN UINT16 DefaultClass, + OUT EDKII_REDFISH_VALUE *Value + ); + /** Set Redfish value with the given Schema and Configure Language. =20 @@ -93,6 +172,29 @@ EFI_STATUS IN EDKII_REDFISH_VALUE Value ); =20 +/** + Get Redfish attribute value with the given Schema and Configure Language= . + + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance. + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[out] AttributeValue The attribute value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_ATTRIBUTE)( + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue + ); + /** Get the list of Configure Language from platform configuration by the gi= ven Schema and RegexPattern. =20 @@ -143,8 +245,11 @@ EFI_STATUS ); =20 struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL { + UINT64 Revision; EDKII_REDFISH_PLATFORM_CONFIG_GET_VALUE GetValue; EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE SetValue; + EDKII_REDFISH_PLATFORM_CONFIG_GET_DEFAULT_VALUE GetDefaultValue; + EDKII_REDFISH_PLATFORM_CONFIG_GET_ATTRIBUTE GetAttribute; EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG GetConfigureLang; EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA GetSupportedSchema; }; diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c index 971035f27d..96b50b201c 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c @@ -3,6 +3,7 @@ The implementation of EDKII Redfidh Platform Config Protocol. =20 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -13,6 +14,182 @@ =20 REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate =3D NULL; =20 +/** + Get the attribute name from config language. + + For example: /Bios/Attributes/BiosOption1 is config laugnage + and attribute name is BiosOption1. + + @param[in] ConfigLanguage Config language string. + + @retval CHAR8 * Attribute name string. + @retval NULL Can not find attribute name. + +**/ +CHAR8 * +GetAttributeNameFromConfigLanguage ( + IN CHAR8 *ConfigLanguage + ) +{ + CHAR8 *attributeName; + CHAR8 *Pointer; + UINTN StrLen; + UINTN Index; + UINTN AttrStrLen; + + if (IS_EMPTY_STRING (ConfigLanguage)) { + return NULL; + } + + attributeName =3D NULL; + Pointer =3D NULL; + AttrStrLen =3D 0; + StrLen =3D AsciiStrLen (ConfigLanguage); + + if (ConfigLanguage[StrLen - 1] =3D=3D '/') { + // + // wrong format + // + DEBUG ((DEBUG_ERROR, "%a, invalid format: %a\n", __FUNCTION__, ConfigL= anguage)); + ASSERT (FALSE); + return NULL; + } + + Index =3D StrLen; + while (TRUE) { + Index -=3D 1; + + if (ConfigLanguage[Index] =3D=3D '/') { + Pointer =3D &ConfigLanguage[Index + 1]; + break; + } + + if (Index =3D=3D 0) { + break; + } + } + + // + // Not found. There is no '/' in input string. + // + if (Pointer =3D=3D NULL) { + return NULL; + } + + AttrStrLen =3D StrLen - Index; + attributeName =3D AllocateCopyPool (AttrStrLen, Pointer); + + return attributeName; +} + +/** + Convert one-of options to string array in Redfish attribute. + + @param[in] HiiHandle HII handle. + @param[in] SchemaName Schema string. + @param[in] HiiStatement Target HII statement. + @param[out] Values Attribute value array. + + @retval EFI_SUCCESS Options are converted successfully. + @retval Other Error occurs. + +**/ +EFI_STATUS +OneOfStatementToAttributeValues ( + IN EFI_HII_HANDLE HiiHandle, + IN CHAR8 *SchemaName, + IN HII_STATEMENT *HiiStatement, + OUT EDKII_REDFISH_POSSIBLE_VALUES *Values + ) +{ + LIST_ENTRY *Link; + HII_QUESTION_OPTION *Option; + UINTN Index; + + if ((HiiHandle =3D=3D NULL) || (HiiStatement =3D=3D NULL) || (Values =3D= =3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + if (IsListEmpty (&HiiStatement->OptionListHead)) { + return EFI_NOT_FOUND; + } + + // + // Loop through the option to get count + // + Values->ValueCount =3D 0; + Link =3D GetFirstNode (&HiiStatement->OptionListHead); + while (!IsNull (&HiiStatement->OptionListHead, Link)) { + Values->ValueCount +=3D 1; + Link =3D GetNextNode (&HiiStatement->OptionListHead, Li= nk); + } + + Values->ValueArray =3D AllocateZeroPool (sizeof (EDKII_REDFISH_ATTRIBUTE= _VALUE) * Values->ValueCount); + if (Values->ValueArray =3D=3D NULL) { + Values->ValueCount =3D 0; + return EFI_OUT_OF_RESOURCES; + } + + Index =3D 0; + Link =3D GetFirstNode (&HiiStatement->OptionListHead); + while (!IsNull (&HiiStatement->OptionListHead, Link)) { + Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); + + if (Option->Text !=3D 0) { + Values->ValueArray[Index].ValueName =3D HiiGetRedfishAsciiString (Hi= iHandle, SchemaName, Option->Text); + Values->ValueArray[Index].ValueName =3D HiiGetEnglishAsciiString (Hi= iHandle, Option->Text); + } + + Index +=3D 1; + Link =3D GetNextNode (&HiiStatement->OptionListHead, Link); + } + + return EFI_SUCCESS; +} + +/** + Return Redfish attribute type from given HII statment operand. + + @param[in] HiiStatement Target HII statement. + + @retval EDKII_REDFISH_ATTRIBUTE_TYPES Attribute type. + +**/ +EDKII_REDFISH_ATTRIBUTE_TYPES +HiiStatementToAttributeType ( + IN HII_STATEMENT *HiiStatement + ) +{ + EDKII_REDFISH_ATTRIBUTE_TYPES type; + + if (HiiStatement =3D=3D NULL) { + return REDFISH_ATTRIBUTE_TYPE_UNKNOWN; + } + + type =3D REDFISH_ATTRIBUTE_TYPE_UNKNOWN; + switch (HiiStatement->Operand) { + case EFI_IFR_ONE_OF_OP: + case EFI_IFR_ORDERED_LIST_OP: + type =3D REDFISH_ATTRIBUTE_TYPE_ENUMERATION; + break; + case EFI_IFR_STRING_OP: + type =3D REDFISH_ATTRIBUTE_TYPE_STRING; + break; + case EFI_IFR_NUMERIC_OP: + type =3D REDFISH_ATTRIBUTE_TYPE_INTEGER; + break; + case EFI_IFR_CHECKBOX_OP: + type =3D REDFISH_ATTRIBUTE_TYPE_BOOLEAN; + break; + case EFI_IFR_DATE_OP: + case EFI_IFR_TIME_OP: + default: + DEBUG ((DEBUG_ERROR, "%a, unsupported operand: 0x%x\n", __FUNCTION__= , HiiStatement->Operand)); + break; + } + + return type; +} =20 /** Zero extend integer/boolean to UINT64 for comparing. @@ -264,7 +441,8 @@ CompareHiiStatementValue ( /** Convert HII value to the string in HII one-of opcode. =20 - @param[in] Statement Statement private instance + @param[in] HiiStatement HII Statement private instance + @param[in] Value HII Statement value =20 @retval EFI_STRING_ID The string ID in HII database. 0 is returned when something goes wrong. @@ -272,29 +450,34 @@ CompareHiiStatementValue ( **/ EFI_STRING_ID HiiValueToOneOfOptionStringId ( - IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement + IN HII_STATEMENT *HiiStatement, + IN HII_STATEMENT_VALUE *Value ) { LIST_ENTRY *Link; HII_QUESTION_OPTION *Option; =20 - if (Statement->HiiStatement->Operand !=3D EFI_IFR_ONE_OF_OP) { + if ((HiiStatement =3D=3D NULL) || (Value =3D=3D NULL)) { return 0; } =20 - if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) { + if (HiiStatement->Operand !=3D EFI_IFR_ONE_OF_OP) { return 0; } =20 - Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead); - while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) { + if (IsListEmpty (&HiiStatement->OptionListHead)) { + return 0; + } + + Link =3D GetFirstNode (&HiiStatement->OptionListHead); + while (!IsNull (&HiiStatement->OptionListHead, Link)) { Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); =20 - if (CompareHiiStatementValue (&Statement->HiiStatement->Value, &Option= ->Value) =3D=3D 0) { + if (CompareHiiStatementValue (Value, &Option->Value) =3D=3D 0) { return Option->Text; } =20 - Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link); + Link =3D GetNextNode (&HiiStatement->OptionListHead, Link); } =20 return 0; @@ -531,7 +714,7 @@ DumpOrderedListValue ( Convert HII value to the string in HII ordered list opcode. It's caller'= s responsibility to free returned buffer using FreePool(). =20 - @param[in] Statement Statement private instance + @param[in] HiiStatement HII Statement private instance @param[out] ReturnSize The size of returned array =20 @retval EFI_STRING_ID The string ID array for options in ordered lis= t. @@ -539,8 +722,8 @@ DumpOrderedListValue ( **/ EFI_STRING_ID * HiiValueToOrderedListOptionStringId ( - IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement, - OUT UINTN *ReturnSize + IN HII_STATEMENT *HiiStatement, + OUT UINTN *ReturnSize ) { LIST_ENTRY *Link; @@ -550,32 +733,32 @@ HiiValueToOrderedListOptionStringId ( UINTN Index; UINT64 Value; =20 - if (Statement =3D=3D NULL || ReturnSize =3D=3D NULL) { + if ((HiiStatement =3D=3D NULL) || (ReturnSize =3D=3D NULL)) { return NULL; } =20 *ReturnSize =3D 0; =20 - if (Statement->HiiStatement->Operand !=3D EFI_IFR_ORDERED_LIST_OP) { + if (HiiStatement->Operand !=3D EFI_IFR_ORDERED_LIST_OP) { return NULL; } =20 - if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) { + if (IsListEmpty (&HiiStatement->OptionListHead)) { return NULL; } =20 DEBUG_CODE ( - DumpOrderedListValue (Statement->HiiStatement); - ); + DumpOrderedListValue (HiiStatement); + ); =20 OptionCount =3D 0; - Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead); - while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) { + Link =3D GetFirstNode (&HiiStatement->OptionListHead); + while (!IsNull (&HiiStatement->OptionListHead, Link)) { Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); =20 ++OptionCount; =20 - Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link); + Link =3D GetNextNode (&HiiStatement->OptionListHead, Link); } =20 *ReturnSize =3D OptionCount; @@ -587,8 +770,8 @@ HiiValueToOrderedListOptionStringId ( } =20 for (Index =3D 0; Index < OptionCount; Index++) { - Value =3D OrderedListGetArrayData (Statement->HiiStatement->Value.Buff= er, Statement->HiiStatement->Value.BufferValueType, Index); - ReturnedArray[Index] =3D OrderedListOptionValueToStringId (Statement->= HiiStatement, Value); + Value =3D OrderedListGetArrayData (HiiStatement->Value.= Buffer, HiiStatement->Value.BufferValueType, Index); + ReturnedArray[Index] =3D OrderedListOptionValueToStringId (HiiStatemen= t, Value); } =20 return ReturnedArray; @@ -657,6 +840,126 @@ HiiStringToOrderedListOptionValue ( return EFI_NOT_FOUND; } =20 +/** + Convert HII value to Redfish value. + + @param[in] HiiHandle HII handle. + @param[in] FullSchema Schema string. + @param[in] HiiStatement HII statement. + @param[in] Value Value to be converted. + @param[out] RedfishValue Value in Redfish format. + + @retval EFI_SUCCESS Redfish value is returned successfully. + @retval Others Errors occur + +**/ +EFI_STATUS +HiiValueToRedfishValue ( + IN EFI_HII_HANDLE HiiHandle, + IN CHAR8 *FullSchema, + IN HII_STATEMENT *HiiStatement, + IN HII_STATEMENT_VALUE *Value, + OUT EDKII_REDFISH_VALUE *RedfishValue + ) +{ + EFI_STATUS Status; + EFI_STRING_ID StringId; + UINTN Index; + UINTN Count; + EFI_STRING_ID *StringIdArray; + + if ((HiiHandle =3D=3D NULL) || (HiiStatement =3D=3D NULL) || (Value =3D= =3D NULL) || (RedfishValue =3D=3D NULL) || IS_EMPTY_STRING (FullSchema)) { + return EFI_INVALID_PARAMETER; + } + + StringIdArray =3D NULL; + Count =3D 0; + + switch (HiiStatement->Operand) { + case EFI_IFR_ONE_OF_OP: + StringId =3D HiiValueToOneOfOptionStringId (HiiStatement, Value); + if (StringId =3D=3D 0) { + ASSERT (FALSE); + Status =3D EFI_DEVICE_ERROR; + break; + } + + RedfishValue->Value.Buffer =3D HiiGetRedfishAsciiString (HiiHandle, = FullSchema, StringId); + if (RedfishValue->Value.Buffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + break; + } + + RedfishValue->Type =3D REDFISH_VALUE_TYPE_STRING; + break; + case EFI_IFR_STRING_OP: + if (Value->Type !=3D EFI_IFR_TYPE_STRING) { + ASSERT (FALSE); + Status =3D EFI_DEVICE_ERROR; + break; + } + + RedfishValue->Type =3D REDFISH_VALUE_TYPE_STRING; + RedfishValue->Value.Buffer =3D AllocatePool (StrLen ((CHAR16 *)Value= ->Buffer) + 1); + UnicodeStrToAsciiStrS ((CHAR16 *)Value->Buffer, RedfishValue->Value.= Buffer, StrLen ((CHAR16 *)Value->Buffer) + 1); + break; + case EFI_IFR_CHECKBOX_OP: + case EFI_IFR_NUMERIC_OP: + Status =3D HiiValueToRedfishNumeric (Value, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish v= alue: %r\n", __FUNCTION__, Status)); + break; + } + + break; + case EFI_IFR_ACTION_OP: + if (Value->Type !=3D EFI_IFR_TYPE_ACTION) { + ASSERT (FALSE); + Status =3D EFI_DEVICE_ERROR; + break; + } + + // + // Action has no value. Just return unknown type. + // + RedfishValue->Type =3D REDFISH_VALUE_TYPE_UNKNOWN; + break; + case EFI_IFR_ORDERED_LIST_OP: + StringIdArray =3D HiiValueToOrderedListOptionStringId (HiiStatement,= &Count); + if (StringIdArray =3D=3D NULL) { + ASSERT (FALSE); + Status =3D EFI_DEVICE_ERROR; + break; + } + + RedfishValue->Value.StringArray =3D AllocatePool (sizeof (CHAR8 *) *= Count); + if (RedfishValue->Value.StringArray =3D=3D NULL) { + ASSERT (FALSE); + Status =3D EFI_OUT_OF_RESOURCES; + break; + } + + for (Index =3D 0; Index < Count; Index++) { + ASSERT (StringIdArray[Index] !=3D 0); + RedfishValue->Value.StringArray[Index] =3D HiiGetRedfishAsciiStrin= g (HiiHandle, FullSchema, StringIdArray[Index]); + ASSERT (RedfishValue->Value.StringArray[Index] !=3D NULL); + } + + RedfishValue->ArrayCount =3D Count; + RedfishValue->Type =3D REDFISH_VALUE_TYPE_STRING_ARRAY; + + FreePool (StringIdArray); + break; + default: + DEBUG ((DEBUG_ERROR, "%a, catch unsupported type: 0x%x! Please conta= ct with author if we need to support this type.\n", __FUNCTION__, HiiStatem= ent->Operand)); + ASSERT (FALSE); + Status =3D EFI_UNSUPPORTED; + break; + } + + return Status; +} + /** Convert input ascii string to unicode string. It's caller's responsibility to free returned buffer using FreePool(). @@ -825,12 +1128,7 @@ RedfishPlatformConfigProtocolGetValue ( EFI_STATUS Status; REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate; REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement; - EFI_STRING_ID StringId; - EFI_STRING_ID *StringIdArray; CHAR8 *FullSchema; - EFI_STRING HiiString; - UINTN Count; - UINTN Index; =20 if (This =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Ver= sion) || IS_EMPTY_STRING (ConfigureLang) || Value =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -839,10 +1137,7 @@ RedfishPlatformConfigProtocolGetValue ( RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); Value->Type =3D REDFISH_VALUE_TYPE_UNKNOWN; Value->ArrayCount =3D 0; - Count =3D 0; FullSchema =3D NULL; - HiiString =3D NULL; - StringIdArray =3D NULL; =20 FullSchema =3D GetFullSchemaString (Schema, Version); if (FullSchema =3D=3D NULL) { @@ -854,82 +1149,15 @@ RedfishPlatformConfigProtocolGetValue ( goto RELEASE_RESOURCE; } =20 - switch (TargetStatement->HiiStatement->Operand) { - case EFI_IFR_ONE_OF_OP: - StringId =3D HiiValueToOneOfOptionStringId (TargetStatement); - if (StringId =3D=3D 0) { - ASSERT (FALSE); - Status =3D EFI_DEVICE_ERROR; - goto RELEASE_RESOURCE; - } - - Value->Value.Buffer =3D HiiGetRedfishAsciiString (TargetStatement->P= arentForm->ParentFormset->HiiHandle, FullSchema, StringId); - if (Value->Value.Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto RELEASE_RESOURCE; - } - - Value->Type =3D REDFISH_VALUE_TYPE_STRING; - break; - case EFI_IFR_STRING_OP: - if (TargetStatement->HiiStatement->Value.Type !=3D EFI_IFR_TYPE_STRI= NG) { - ASSERT (FALSE); - Status =3D EFI_DEVICE_ERROR; - goto RELEASE_RESOURCE; - } - - Value->Type =3D REDFISH_VALUE_TYPE_STRING; - Value->Value.Buffer =3D AllocatePool (StrLen ((CHAR16 *)TargetStatem= ent->HiiStatement->Value.Buffer) + 1); - UnicodeStrToAsciiStrS ((CHAR16 *)TargetStatement->HiiStatement->Valu= e.Buffer, Value->Value.Buffer, StrLen ((CHAR16 *)TargetStatement->HiiStatem= ent->Value.Buffer) + 1); - break; - case EFI_IFR_CHECKBOX_OP: - case EFI_IFR_NUMERIC_OP: - Status =3D HiiValueToRedfishNumeric (&TargetStatement->HiiStatement-= >Value, Value); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish v= alue: %r\n", __FUNCTION__, Status)); - goto RELEASE_RESOURCE; - } - break; - case EFI_IFR_ACTION_OP: - if (TargetStatement->HiiStatement->Value.Type !=3D EFI_IFR_TYPE_ACTI= ON) { - ASSERT (FALSE); - Status =3D EFI_DEVICE_ERROR; - goto RELEASE_RESOURCE; - } - - // - // Action has no value. Just return unknown type. - // - Value->Type =3D REDFISH_VALUE_TYPE_UNKNOWN; - break; - case EFI_IFR_ORDERED_LIST_OP: - StringIdArray =3D HiiValueToOrderedListOptionStringId (TargetStateme= nt, &Count); - if (StringIdArray =3D=3D NULL) { - ASSERT (FALSE); - Status =3D EFI_DEVICE_ERROR; - goto RELEASE_RESOURCE; - } - - Value->Value.StringArray =3D AllocatePool (sizeof (CHAR8 *) * Count)= ; - if (Value->Value.StringArray =3D=3D NULL) { - ASSERT (FALSE); - Status =3D EFI_OUT_OF_RESOURCES; - goto RELEASE_RESOURCE; - } - - for (Index =3D 0; Index < Count; Index++) { - ASSERT (StringIdArray[Index] !=3D 0); - Value->Value.StringArray[Index] =3D HiiGetRedfishAsciiString (Targ= etStatement->ParentForm->ParentFormset->HiiHandle, FullSchema, StringIdArra= y[Index]); - } - - Value->ArrayCount =3D Count; - Value->Type =3D REDFISH_VALUE_TYPE_STRING_ARRAY; - break; - default: - DEBUG ((DEBUG_ERROR, "%a, catch unsupported type: 0x%x! Please conta= ct with author if we need to support this type.\n", __FUNCTION__, TargetSta= tement->HiiStatement->Operand)); - ASSERT (FALSE); - Status =3D EFI_UNSUPPORTED; - goto RELEASE_RESOURCE; + Status =3D HiiValueToRedfishValue ( + TargetStatement->ParentForm->ParentFormset->HiiHandle, + FullSchema, + TargetStatement->HiiStatement, + &TargetStatement->HiiStatement->Value, + Value + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, HiiValueToRedfishValue failed: %r\n", __FUNC= TION__, Status)); } =20 RELEASE_RESOURCE: @@ -938,14 +1166,6 @@ RELEASE_RESOURCE: FreePool (FullSchema); } =20 - if (HiiString !=3D NULL) { - FreePool (HiiString); - } - - if (StringIdArray !=3D NULL) { - FreePool (StringIdArray); - } - return Status; } =20 @@ -1433,6 +1653,176 @@ RedfishPlatformConfigProtocolGetSupportedSchema ( return EFI_SUCCESS; } =20 +/** + Get Redfish default value with the given Schema and Configure Language. + + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance. + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[in] DefaultClass The UEFI defined default class. + Please refer to UEFI spec. 33.2.5.8 "de= faults" for details. + @param[out] Value The returned value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigProtocolGetDefaultValue ( + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN UINT16 DefaultClass, + OUT EDKII_REDFISH_VALUE *Value + ) +{ + EFI_STATUS Status; + REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate= ; + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement; + CHAR8 *FullSchema; + HII_STATEMENT_VALUE DefaultValue; + + if ((This =3D=3D NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (V= ersion) || IS_EMPTY_STRING (ConfigureLang) || (Value =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); + Value->Type =3D REDFISH_VALUE_TYPE_UNKNOWN; + Value->ArrayCount =3D 0; + + FullSchema =3D NULL; + FullSchema =3D GetFullSchemaString (Schema, Version); + if (FullSchema =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status =3D RedfishPlatformConfigGetStatementCommon (RedfishPlatformConfi= gPrivate, FullSchema, ConfigureLang, &TargetStatement); + if (EFI_ERROR (Status)) { + goto RELEASE_RESOURCE; + } + + Status =3D GetQuestionDefault (TargetStatement->ParentForm->ParentFormse= t->HiiFormSet, TargetStatement->ParentForm->HiiForm, TargetStatement->HiiSt= atement, DefaultClass, &DefaultValue); + if (EFI_ERROR (Status)) { + goto RELEASE_RESOURCE; + } + + Status =3D HiiValueToRedfishValue ( + TargetStatement->ParentForm->ParentFormset->HiiHandle, + FullSchema, + TargetStatement->HiiStatement, + &DefaultValue, + Value + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, HiiValueToRedfishValue failed: %r\n", __FUNC= TION__, Status)); + } + +RELEASE_RESOURCE: + + if (FullSchema !=3D NULL) { + FreePool (FullSchema); + } + + return Status; +} + +/** + Get Redfish attribute value with the given Schema and Configure Language= . + + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance. + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[out] AttributeValue The attribute value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigProtocolGetAttribute ( + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue + ) +{ + EFI_STATUS Status; + REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate= ; + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement; + CHAR8 *FullSchema; + CHAR8 *Buffer; + + if ((This =3D=3D NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (V= ersion) || IS_EMPTY_STRING (ConfigureLang) || (AttributeValue =3D=3D NULL))= { + return EFI_INVALID_PARAMETER; + } + + RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); + ZeroMem (AttributeValue, sizeof (EDKII_REDFISH_ATTRIBUTE)); + FullSchema =3D NULL; + FullSchema =3D GetFullSchemaString (Schema, Version); + if (FullSchema =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status =3D RedfishPlatformConfigGetStatementCommon (RedfishPlatformConfi= gPrivate, FullSchema, ConfigureLang, &TargetStatement); + if (EFI_ERROR (Status)) { + goto RELEASE_RESOURCE; + } + + if (TargetStatement->Description !=3D 0) { + AttributeValue->AttributeName =3D HiiGetRedfishAsciiString (TargetStat= ement->ParentForm->ParentFormset->HiiHandle, FullSchema, TargetStatement->D= escription); + Buffer =3D GetAttributeNameFromConfigLanguage (= AttributeValue->AttributeName); + if (Buffer !=3D NULL) { + FreePool (AttributeValue->AttributeName); + AttributeValue->AttributeName =3D Buffer; + } + + AttributeValue->DisplayName =3D HiiGetEnglishAsciiString (TargetStatem= ent->ParentForm->ParentFormset->HiiHandle, TargetStatement->Description); + } + + if (TargetStatement->Help !=3D 0) { + AttributeValue->HelpText =3D HiiGetEnglishAsciiString (TargetStatement= ->ParentForm->ParentFormset->HiiHandle, TargetStatement->Help); + } + + AttributeValue->ReadOnly =3D ((TargetStatement->Flags & EFI_IFR_FLA= G_READ_ONLY) =3D=3D 0 ? FALSE : TRUE); + AttributeValue->ResetRequired =3D ((TargetStatement->Flags & EFI_IFR_FLA= G_RESET_REQUIRED) =3D=3D 0 ? FALSE : TRUE); + AttributeValue->Type =3D HiiStatementToAttributeType (TargetSta= tement->HiiStatement); + + // + // Deal with maximum and minimum + // + if (AttributeValue->Type =3D=3D REDFISH_ATTRIBUTE_TYPE_STRING) { + AttributeValue->StrMaxSize =3D TargetStatement->StatementData.StrMaxSi= ze; + AttributeValue->StrMinSize =3D TargetStatement->StatementData.StrMinSi= ze; + } else if (AttributeValue->Type =3D=3D REDFISH_ATTRIBUTE_TYPE_INTEGER) { + AttributeValue->NumMaximum =3D TargetStatement->StatementData.NumMaxim= um; + AttributeValue->NumMinimum =3D TargetStatement->StatementData.NumMinim= um; + AttributeValue->NumStep =3D TargetStatement->StatementData.NumStep; + } + + // + // Provide value array if this is enumeration type. + // + if (TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_ONE_OF_OP) { + Status =3D OneOfStatementToAttributeValues (TargetStatement->ParentFor= m->ParentFormset->HiiHandle, FullSchema, TargetStatement->HiiStatement, &At= tributeValue->Values); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to convert one-of options to attrib= ute values: %r\n", __FUNCTION__, Status)); + } + } + +RELEASE_RESOURCE: + + if (FullSchema !=3D NULL) { + FreePool (FullSchema); + } + + return Status; +} + /** Functions which are registered to receive notification of database events have this prototype. The actual event is encoded @@ -1715,10 +2105,13 @@ RedfishPlatformConfigDxeEntryPoint ( // Protocol initialization // mRedfishPlatformConfigPrivate->ImageHandle =3D ImageHandle; - mRedfishPlatformConfigPrivate->Protocol.GetValue =3D RedfishPlatformConf= igProtocolGetValue; - mRedfishPlatformConfigPrivate->Protocol.SetValue =3D RedfishPlatformConf= igProtocolSetValue; - mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang =3D RedfishPlat= formConfigProtocolGetConfigureLang; + mRedfishPlatformConfigPrivate->Protocol.Revision =3D REDFISH_P= LATFORM_CONFIG_VERSION; + mRedfishPlatformConfigPrivate->Protocol.GetValue =3D RedfishPl= atformConfigProtocolGetValue; + mRedfishPlatformConfigPrivate->Protocol.SetValue =3D RedfishPl= atformConfigProtocolSetValue; + mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang =3D RedfishPl= atformConfigProtocolGetConfigureLang; mRedfishPlatformConfigPrivate->Protocol.GetSupportedSchema =3D RedfishPl= atformConfigProtocolGetSupportedSchema; + mRedfishPlatformConfigPrivate->Protocol.GetAttribute =3D RedfishPl= atformConfigProtocolGetAttribute; + mRedfishPlatformConfigPrivate->Protocol.GetDefaultValue =3D RedfishPl= atformConfigProtocolGetDefaultValue; =20 InitializeListHead (&mRedfishPlatformConfigPrivate->FormsetList); InitializeListHead (&mRedfishPlatformConfigPrivate->PendingList); diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h index d3f7af55ad..8155484702 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h @@ -2,6 +2,7 @@ This file defines the EDKII Redfish Platform Config Protocol interface. =20 (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -60,5 +61,6 @@ typedef struct { #define REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS(a) BASE_CR (a, REDFISH_= PLATFORM_CONFIG_PRIVATE, Protocol) #define REGULAR_EXPRESSION_INCLUDE_ALL L".*" #define CONFIGURE_LANGUAGE_PREFIX "x-uefi-redfish-" +#define REDFISH_PLATFORM_CONFIG_VERSION 0x00010000 =20 #endif diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.= c b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c index b2bb5f64e4..65a0e5766a 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c @@ -3,6 +3,7 @@ The implementation of EDKII Redfish Platform Config Protocol. =20 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -300,6 +301,45 @@ HiiGetEnglishString ( return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId); } =20 +/** + Get ASCII string from HII database in English language. + + @param[in] HiiHandle A handle that was previously registered in= the HII Database. + @param[in] StringId The identifier of the string to retrieved = from the string + package associated with HiiHandle. + + @retval NULL The string specified by StringId is not present in the st= ring package. + @retval Other The string was returned. + +**/ +CHAR8 * +HiiGetEnglishAsciiString ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_STRING_ID StringId + ) +{ + EFI_STRING HiiString; + UINTN StringSize; + CHAR8 *AsciiString; + + HiiString =3D HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, Str= ingId); + if (HiiString =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Can not find string ID: 0x%x with %a\n", __F= UNCTION__, StringId, ENGLISH_LANGUAGE_CODE)); + return NULL; + } + + StringSize =3D (StrLen (HiiString) + 1) * sizeof (CHAR8); + AsciiString =3D AllocatePool (StringSize); + if (AsciiString =3D=3D NULL) { + return NULL; + } + + UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize); + + FreePool (HiiString); + return AsciiString; +} + /** Check and see if this is supported schema or not. =20 @@ -885,10 +925,17 @@ LoadFormset ( // // Initialize statement private data. // - HiiStatementPrivate->HiiStatement =3D HiiStatement; - HiiStatementPrivate->QuestionId =3D HiiStatement->QuestionId; - HiiStatementPrivate->Description =3D HiiStatement->Prompt; - HiiStatementPrivate->ParentForm =3D HiiFormPrivate; + HiiStatementPrivate->HiiStatement =3D HiiStatement; + HiiStatementPrivate->QuestionId =3D HiiStatement->Ques= tionId; + HiiStatementPrivate->Description =3D HiiStatement->Prom= pt; + HiiStatementPrivate->Help =3D HiiStatement->Help= ; + HiiStatementPrivate->ParentForm =3D HiiFormPrivate; + HiiStatementPrivate->Flags =3D HiiStatement->Ques= tionFlags; + HiiStatementPrivate->StatementData.NumMaximum =3D HiiStatement->Extr= aData.NumData.Maximum; + HiiStatementPrivate->StatementData.NumMinimum =3D HiiStatement->Extr= aData.NumData.Minimum; + HiiStatementPrivate->StatementData.NumStep =3D HiiStatement->Extr= aData.NumData.Step; + HiiStatementPrivate->StatementData.StrMaxSize =3D HiiStatement->Extr= aData.StrData.MaxSize; + HiiStatementPrivate->StatementData.StrMinSize =3D HiiStatement->Extr= aData.StrData.MinSize; =20 // // Attach to statement list. diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.= h b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h index cd7a52aef3..f66f5a8799 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h @@ -2,6 +2,7 @@ This file defines the EDKII Redfish Platform Config Protocol interface. =20 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -74,16 +75,30 @@ typedef struct { =20 #define REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK(a) BASE_CR (a, REDFISH_PLA= TFORM_CONFIG_FORM_PRIVATE, Link) =20 +// +// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_DATA +// +typedef struct { + UINT64 NumMinimum; + UINT64 NumMaximum; + UINT64 NumStep; + UINT8 StrMinSize; + UINT8 StrMaxSize; +} REDFISH_PLATFORM_CONFIG_STATEMENT_DATA; + // // Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE // typedef struct { - LIST_ENTRY Link; - REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *ParentForm; - HII_STATEMENT *HiiStatement; // Pointer to HII = statement data. - EFI_QUESTION_ID QuestionId; // Question ID of = this statement. - EFI_STRING_ID Description; // String token of= this question. - EFI_STRING DesStringCache; // The string cach= e for search function. + LIST_ENTRY Link; + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *ParentForm; + HII_STATEMENT *HiiStatement; // Pointer to = HII statement data. + EFI_QUESTION_ID QuestionId; // Question ID= of this statement. + EFI_STRING_ID Description; // String toke= n of this question. + EFI_STRING_ID Help; // String toke= n of help message. + EFI_STRING DesStringCache; // The string = cache for search function. + UINT8 Flags; // The stateme= nt flag. + REDFISH_PLATFORM_CONFIG_STATEMENT_DATA StatementData; // The max/min= for statement value. } REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE; =20 #define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a) BASE_CR (a, REDFIS= H_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link) @@ -280,6 +295,23 @@ HiiGetRedfishAsciiString ( IN EFI_STRING_ID StringId ); =20 +/** + Get ASCII string from HII database in English language. + + @param[in] HiiHandle A handle that was previously registered in= the HII Database. + @param[in] StringId The identifier of the string to retrieved = from the string + package associated with HiiHandle. + + @retval NULL The string specified by StringId is not present in the st= ring package. + @retval Other The string was returned. + +**/ +CHAR8 * +HiiGetEnglishAsciiString ( + IN EFI_HII_HANDLE HiiHandle, + IN EFI_STRING_ID StringId + ); + /** Release all resource in statement list. =20 --=20 2.38.1.windows.1