From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.3309.1652761179819603907 for ; Mon, 16 May 2022 21:19:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=OKlI3gLD; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0136f5c930=nickle.wang@hpe.com) Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GN1u0r002599 for ; Tue, 17 May 2022 04:19:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pps0720; bh=bH6qzSUQAiTHcKxeAXWjy6irB3dkKxkWAWd8bHDVTPU=; b=OKlI3gLDWLMbB5ozP8C+kuP6hgLgIed8RyUEFjlY5gf7tW8pJvhGz/5Y+93UTyx+4rBS wgUvXUCNG83jqSBumkWTE69tLolkxwCuD/kX7tuQj6SwwE7/24/Mj81ZAHQeEo/K8E8Z i0oYuUgfbgWGF0MhLLQKOjPKW3QXyJm6bRMkBi40GTqQwvCE5f7dfnS0jK1HFEMoYAqC 8QIouVLV1m2chG6KpV2b/uQ2P6U4GYrAOuGBLZFqVF9gcBBdYbJ3mg6Fyn7dFv5/2lxc iPtdWcQX0xyD+W6UcYmWFAD3UWvfNq4cNvst1pOfiaUXE2kMPxd48hxb005VoPSgJuc3 UQ== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3g3wr7vrcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 May 2022 04:19:37 +0000 Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id 5E93C54 for ; Tue, 17 May 2022 04:19:37 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [10.43.61.53]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id E386748; Tue, 17 May 2022 04:19:35 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Nickle Wang , Abner Chang Subject: [edk2-staging][PATCH] edk2-staging/RedfishClientPkg: Add support of array type attribute Date: Tue, 17 May 2022 12:19:25 +0800 Message-Id: <20220517041925.577-1-nickle.wang@hpe.com> X-Mailer: git-send-email 2.32.0.windows.2 MIME-Version: 1.0 X-Proofpoint-GUID: KF4Vc4a9tVgJPg-FMg9YKsdwuiheL7gD X-Proofpoint-ORIG-GUID: KF4Vc4a9tVgJPg-FMg9YKsdwuiheL7gD X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-17_01,2022-05-16_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205170026 Content-Transfer-Encoding: quoted-printable Add Redfish array type attribute support. Add function to handle HII ordered list question in order to convert value array in HII ordered list to Redfish array attribute. Signed-off-by: Nickle Wang Cc: Abner Chang --- .../Protocol/EdkIIRedfishPlatformConfig.h | 299 +- .../RedfishPlatformConfigDxe.c | 3112 ++++++++++------- .../RedfishPlatformConfigDxe.h | 128 +- .../RedfishPlatformConfigDxe.inf | 104 +- .../RedfishPlatformConfigImpl.c | 2526 ++++++------- .../RedfishPlatformConfigImpl.h | 572 +-- 6 files changed, 3660 insertions(+), 3081 deletions(-) diff --git a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h b/Red= fishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h index 895b010227..8c11021eeb 100644 --- a/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h +++ b/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h @@ -1,147 +1,152 @@ -/** @file - This file defines the EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL interface. - - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef EDKII_REDFISH_PLATFORM_CONFIG_H_ -#define EDKII_REDFISH_PLATFORM_CONFIG_H_ - -typedef struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL EDKII_REDFISH_PLATF= ORM_CONFIG_PROTOCOL; - -/** - Definition of EDKII_REDFISH_TYPE_VALUE - **/ -typedef union { - INT64 Integer; - BOOLEAN Boolean; - CHAR8 *Buffer; -} EDKII_REDFISH_TYPE_VALUE; - -/** - Definition of EDKII_REDFISH_VALUE_TYPES - **/ -typedef enum { - REDFISH_VALUE_TYPE_UNKNOWN =3D 0, - REDFISH_VALUE_TYPE_INTEGER, - REDFISH_VALUE_TYPE_BOOLEAN, - REDFISH_VALUE_TYPE_STRING, - REDFISH_VALUE_TYPE_MAX -} EDKII_REDFISH_VALUE_TYPES; - -/** - Definition of EDKII_REDFISH_VALUE - **/ -typedef struct { - EDKII_REDFISH_VALUE_TYPES Type; - EDKII_REDFISH_TYPE_VALUE Value; -} EDKII_REDFISH_VALUE; - -/** - Get Redfish 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] 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_VALUE) ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING ConfigureLang, - OUT EDKII_REDFISH_VALUE *Value - ); - -/** - Set Redfish 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] Value The value to set. - - @retval EFI_SUCCESS Value is returned successfully. - @retval Others Some error happened. - -**/ -typedef -EFI_STATUS -(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE) ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING ConfigureLang, - IN EDKII_REDFISH_VALUE Value - ); - -/** - Get the list of Configure Language from platform configuration by the gi= ven Schema and Pattern. - - @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] Pattern The target Configure Language pattern. - @param[out] ConfigureLangList The list of Configure Language. - @param[out] Count The number of Configure Language in Con= figureLangList. - - @retval EFI_SUCCESS ConfigureLangList is returned successfu= lly. - @retval Others Some error happened. - -**/ -typedef -EFI_STATUS -(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG) ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING Pattern, - OUT EFI_STRING **ConfigureLangList, - OUT UINTN *Count - ); - - -/** - Get the list of supported Redfish schema from platform configuration on = the give HII handle. - - @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance. - @param[in] HiiHandle The target handle to search. If handle = is NULL, - this function returns all schema from H= II database. - @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'. - For example: "x-uefi-redfish-Memory.v1_= 7_1;x-uefi-redfish-Boot.v1_0_1" - The SupportedSchema is allocated by the= callee. It's caller's - responsibility to free this buffer usin= g FreePool(). - - @retval EFI_SUCCESS Schema is returned successfully. - @retval Others Some error happened. - -**/ -typedef -EFI_STATUS -(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA) ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN EFI_HII_HANDLE HiiHandle, OPTION= AL - OUT CHAR8 **SupportedSchema - ); - -struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL { - EDKII_REDFISH_PLATFORM_CONFIG_GET_VALUE GetValue; - EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE SetValue; - EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG GetConfigureLang; - EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA GetSupportedSchema; -}; - -extern EFI_GUID gEdkIIRedfishPlatformConfigProtocolGuid; - -#endif +/** @file=0D + This file defines the EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL interface.= =0D +=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef EDKII_REDFISH_PLATFORM_CONFIG_H_=0D +#define EDKII_REDFISH_PLATFORM_CONFIG_H_=0D +=0D +typedef struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL EDKII_REDFISH_PLATF= ORM_CONFIG_PROTOCOL;=0D +=0D +/**=0D + Definition of EDKII_REDFISH_TYPE_VALUE=0D + **/=0D +typedef union {=0D + INT64 Integer;=0D + BOOLEAN Boolean;=0D + CHAR8 *Buffer;=0D + CHAR8 **StringArray;=0D + INT64 *IntegerArray;=0D +} EDKII_REDFISH_TYPE_VALUE;=0D +=0D +/**=0D + Definition of EDKII_REDFISH_VALUE_TYPES=0D + **/=0D +typedef enum {=0D + REDFISH_VALUE_TYPE_UNKNOWN =3D 0,=0D + REDFISH_VALUE_TYPE_INTEGER,=0D + REDFISH_VALUE_TYPE_BOOLEAN,=0D + REDFISH_VALUE_TYPE_STRING,=0D + REDFISH_VALUE_TYPE_STRING_ARRAY,=0D + REDFISH_VALUE_TYPE_INTEGER_ARRAY,=0D + REDFISH_VALUE_TYPE_MAX=0D +} EDKII_REDFISH_VALUE_TYPES;=0D +=0D +/**=0D + Definition of EDKII_REDFISH_VALUE=0D + **/=0D +typedef struct {=0D + EDKII_REDFISH_VALUE_TYPES Type;=0D + EDKII_REDFISH_TYPE_VALUE Value;=0D + UINTN ArrayCount;=0D +} EDKII_REDFISH_VALUE;=0D +=0D +/**=0D + Get Redfish value with the given Schema and Configure Language.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] Schema The Redfish schema to query.=0D + @param[in] Version The Redfish version to query.=0D + @param[in] ConfigureLang The target value which match this confi= gure Language.=0D + @param[out] Value The returned value.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_VALUE) (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version,=0D + IN EFI_STRING ConfigureLang,=0D + OUT EDKII_REDFISH_VALUE *Value=0D + );=0D +=0D +/**=0D + Set Redfish value with the given Schema and Configure Language.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] Schema The Redfish schema to query.=0D + @param[in] Version The Redfish version to query.=0D + @param[in] ConfigureLang The target value which match this confi= gure Language.=0D + @param[in] Value The value to set.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE) (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version,=0D + IN EFI_STRING ConfigureLang,=0D + IN EDKII_REDFISH_VALUE Value=0D + );=0D +=0D +/**=0D + Get the list of Configure Language from platform configuration by the gi= ven Schema and Pattern.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] Schema The Redfish schema to query.=0D + @param[in] Version The Redfish version to query.=0D + @param[in] Pattern The target Configure Language pattern.= =0D + @param[out] ConfigureLangList The list of Configure Language.=0D + @param[out] Count The number of Configure Language in Con= figureLangList.=0D +=0D + @retval EFI_SUCCESS ConfigureLangList is returned successfu= lly.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG) (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version,=0D + IN EFI_STRING Pattern,=0D + OUT EFI_STRING **ConfigureLangList,=0D + OUT UINTN *Count=0D + );=0D +=0D +=0D +/**=0D + Get the list of supported Redfish schema from platform configuration on = the give HII handle.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] HiiHandle The target handle to search. If handle = is NULL,=0D + this function returns all schema from H= II database.=0D + @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'.=0D + For example: "x-uefi-redfish-Memory.v1_= 7_1;x-uefi-redfish-Boot.v1_0_1"=0D + The SupportedSchema is allocated by the= callee. It's caller's=0D + responsibility to free this buffer usin= g FreePool().=0D +=0D + @retval EFI_SUCCESS Schema is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA) (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN EFI_HII_HANDLE HiiHandle, OPTION= AL=0D + OUT CHAR8 **SupportedSchema=0D + );=0D +=0D +struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL {=0D + EDKII_REDFISH_PLATFORM_CONFIG_GET_VALUE GetValue;=0D + EDKII_REDFISH_PLATFORM_CONFIG_SET_VALUE SetValue;=0D + EDKII_REDFISH_PLATFORM_CONFIG_GET_CONFIG_LANG GetConfigureLang;=0D + EDKII_REDFISH_PLATFORM_CONFIG_GET_SUPPORTED_SCHEMA GetSupportedSchema;= =0D +};=0D +=0D +extern EFI_GUID gEdkIIRedfishPlatformConfigProtocolGuid;=0D +=0D +#endif=0D diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c index 67818cccd2..f61bebefef 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c @@ -1,1304 +1,1808 @@ -/** @file - - The implementation of EDKII Redfidh Platform Config Protocol. - - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "RedfishPlatformConfigDxe.h" -#include "RedfishPlatformConfigImpl.h" - -REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate =3D NULL; - -/** - Compare two value in HII statement format. - - @param[in] Value1 Firt value to compare. - @param[in] Value2 Second value to be compared. - - @retval UINTN 0 is retuned when two values are equal. - 1 is returned when first value is greater than sec= ond value. - -1 is returned when second value is greater than f= irst value. - -**/ -UINTN -CompareHiiStatementValue ( - IN HII_STATEMENT_VALUE *Value1, - IN HII_STATEMENT_VALUE *Value2 - ) -{ - INTN Result; - UINT64 Data1; - UINT64 Data2; - - if (Value1 =3D=3D NULL || Value2 =3D=3D NULL) { - return 0xFF; - } - - switch (Value1->Type) { - case EFI_IFR_TYPE_NUM_SIZE_8: - Data1 =3D Value1->Value.u8; - break; - case EFI_IFR_TYPE_NUM_SIZE_16: - Data1 =3D Value1->Value.u16; - break; - case EFI_IFR_TYPE_NUM_SIZE_32: - Data1 =3D Value1->Value.u32; - break; - case EFI_IFR_TYPE_NUM_SIZE_64: - Data1 =3D Value1->Value.u64; - break; - case EFI_IFR_TYPE_BOOLEAN: - Data1 =3D (Value1->Value.b ? 1 : 0); - break; - default: - return 0xFF; - } - - switch (Value2->Type) { - case EFI_IFR_TYPE_NUM_SIZE_8: - Data2 =3D Value2->Value.u8; - break; - case EFI_IFR_TYPE_NUM_SIZE_16: - Data2 =3D Value2->Value.u16; - break; - case EFI_IFR_TYPE_NUM_SIZE_32: - Data2 =3D Value2->Value.u32; - break; - case EFI_IFR_TYPE_NUM_SIZE_64: - Data2 =3D Value2->Value.u64; - break; - case EFI_IFR_TYPE_BOOLEAN: - Data2 =3D (Value2->Value.b ? 1 : 0); - break; - default: - return 0xFF; - } - - Result =3D (Data1 =3D=3D Data2 ? 0 : (Data1 > Data2 ? 1 : -1)); - - return Result; -} - -/** - Convert HII value to the string in HII one-of opcode. - - @param[in] Statement Statement private instance - - @retval EFI_STRING_ID The string ID in HII database. - 0 is returned when something goes wrong. - -**/ -EFI_STRING_ID -HiiValueToOneOfOptionStringId ( - IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement - ) -{ - LIST_ENTRY *Link; - HII_QUESTION_OPTION *Option; - - if (Statement->HiiStatement->Operand !=3D EFI_IFR_ONE_OF_OP) { - return 0; - } - - if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) { - return 0; - } - - Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead); - while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) { - Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); - - if (CompareHiiStatementValue (&Statement->HiiStatement->Value, &Option= ->Value) =3D=3D 0) { - return Option->Text; - } - - Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link); - } - - return 0; -} - -/** - Convert HII string to the value in HII one-of opcode. - - @param[in] Statement Statement private instance - @param[in] Schema Schema string - @param[in] HiiString Input string - @param[out] Value Value returned - - @retval EFI_SUCCESS HII value is returned successfully. - @retval Others Errors occur - -**/ -EFI_STATUS -HiiStringToOneOfOptionValue ( - IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement, - IN CHAR8 *Schema, - IN EFI_STRING HiiString, - OUT HII_STATEMENT_VALUE *Value - ) -{ - LIST_ENTRY *Link; - HII_QUESTION_OPTION *Option; - EFI_STRING TmpString; - BOOLEAN Found; - - if (Statement =3D=3D NULL || IS_EMPTY_STRING (HiiString) || Value =3D=3D= NULL) { - return EFI_INVALID_PARAMETER; - } - - if (Statement->HiiStatement->Operand !=3D EFI_IFR_ONE_OF_OP) { - return EFI_UNSUPPORTED; - } - - if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) { - return EFI_NOT_FOUND; - } - - Found =3D FALSE; - Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead); - while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) { - Option =3D HII_QUESTION_OPTION_FROM_LINK (Link); - - TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentFormse= t->HiiHandle, Schema, Option->Text); - if (TmpString !=3D NULL) { - if (StrCmp (TmpString, HiiString) =3D=3D 0) { - CopyMem (Value, &Option->Value, sizeof (HII_STATEMENT_VALUE)); - Found =3D TRUE; - } - FreePool (TmpString); - } - - if (Found) { - return EFI_SUCCESS; - } - - Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link); - } - - return EFI_NOT_FOUND; -} - -/** - Convert HII value to numeric value in Redfish format. - - @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 -HiiValueToRedfishNumeric ( - IN HII_STATEMENT_VALUE *Value, - OUT EDKII_REDFISH_VALUE *RedfishValue - ) -{ - if (Value =3D=3D NULL || RedfishValue =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - switch (Value->Type) { - case EFI_IFR_TYPE_NUM_SIZE_8: - RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER; - RedfishValue->Value.Integer =3D (INT64)Value->Value.u8; - break; - case EFI_IFR_TYPE_NUM_SIZE_16: - RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER; - RedfishValue->Value.Integer =3D (INT64)Value->Value.u16; - break; - case EFI_IFR_TYPE_NUM_SIZE_32: - RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER; - RedfishValue->Value.Integer =3D (INT64)Value->Value.u32; - break; - case EFI_IFR_TYPE_NUM_SIZE_64: - RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER; - RedfishValue->Value.Integer =3D (INT64)Value->Value.u64; - break; - case EFI_IFR_TYPE_BOOLEAN: - RedfishValue->Type =3D REDFISH_VALUE_TYPE_BOOLEAN; - RedfishValue->Value.Boolean =3D Value->Value.b; - break; - default: - RedfishValue->Type =3D REDFISH_VALUE_TYPE_UNKNOWN; - break; - } - - return EFI_SUCCESS; -} - -/** - Convert numeric value in Redfish format to HII value. - - @param[in] RedfishValue Value in Redfish format to be converted. - @param[out] Value HII value returned. - - @retval EFI_SUCCESS HII value is returned successfully. - @retval Others Errors occur - -**/ -EFI_STATUS -RedfishNumericToHiiValue ( - IN EDKII_REDFISH_VALUE *RedfishValue, - OUT HII_STATEMENT_VALUE *Value - ) -{ - if (Value =3D=3D NULL || RedfishValue =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - switch (RedfishValue->Type) { - case REDFISH_VALUE_TYPE_INTEGER: - Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_64; - Value->Value.u64 =3D (UINT64)RedfishValue->Value.Integer; - break; - case REDFISH_VALUE_TYPE_BOOLEAN: - Value->Type =3D EFI_IFR_TYPE_BOOLEAN; - Value->Value.b =3D RedfishValue->Value.Boolean; - break; - default: - Value->Type =3D EFI_IFR_TYPE_UNDEFINED; - break; - } - - return EFI_SUCCESS; -} - -/** - Return the full Redfish schema string from the given Schema and Version. - - Returned schema string is: Schema + '.' + Version - - @param[in] Schema Schema string - @param[in] Version Schema version string - - @retval CHAR8 * Schema string. NULL when errors occur. - -**/ -CHAR8 * -GetFullSchemaString ( - IN CHAR8 *Schema, - IN CHAR8 *Version - ) -{ - UINTN Size; - CHAR8 *FullName; - - if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version)) { - return NULL; - } - - Size =3D AsciiStrSize(CONFIGURE_LANGUAGE_PREFIX) + AsciiStrSize (Schema)= + AsciiStrSize (Version); - - FullName =3D AllocatePool (Size); - if (FullName =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, out-of-resource\n", __FUNCTION__)); - return NULL; - } - - AsciiSPrint (FullName, Size, "%a%a.%a", CONFIGURE_LANGUAGE_PREFIX, Schem= a, Version); - - return FullName; -} - -/** - Common implementation to get statement private instance. - - @param[in] RedfishPlatformConfigPrivate Private instance. - @param[in] Schema Redfish schema string. - @param[in] ConfigureLang Configure language that refe= rs to this statement. - @param[out] Statement Statement instance - - @retval EFI_SUCCESS HII value is returned successfully. - @retval Others Errors occur - -**/ -EFI_STATUS -RedfishPlatformConfigGetStatementCommon ( - IN REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfig= Private, - IN CHAR8 *Schema, - IN EFI_STRING ConfigureLang, - OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE **Statement - ) -{ - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement; - - if (RedfishPlatformConfigPrivate =3D=3D NULL || IS_EMPTY_STRING (Schema)= || IS_EMPTY_STRING (ConfigureLang) || Statement =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - *Statement =3D NULL; - - Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status)); - return Status; - } - - TargetStatement =3D GetStatementPrivateByConfigureLang (&RedfishPlatform= ConfigPrivate->FormsetList, Schema, ConfigureLang); - if (TargetStatement =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, No match HII statement is found by the given= %s in schema %a\n", __FUNCTION__, ConfigureLang, Schema)); - return EFI_NOT_FOUND; - } - - // - // Find current HII question value. - // - Status =3D GetQuestionValue ( - TargetStatement->ParentForm->ParentFormset->HiiFormSet, - TargetStatement->ParentForm->HiiForm, - TargetStatement->HiiStatement, - GetSetValueWithHiiDriver - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get question current value: %r\n",= __FUNCTION__, Status)); - return Status; - } - - - if (TargetStatement->HiiStatement->Value.Type =3D=3D EFI_IFR_TYPE_UNDEFI= NED) { - return EFI_DEVICE_ERROR; - } - - // - // Return Value. - // - *Statement =3D TargetStatement; - - return EFI_SUCCESS; -} - -/** - Get Redfish 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] Value The returned value. - - @retval EFI_SUCCESS Value is returned successfully. - @retval Others Some error happened. - -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigProtocolGetValue ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING ConfigureLang, - OUT EDKII_REDFISH_VALUE *Value - ) -{ - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement; - EFI_STRING_ID StringId; - CHAR8 *FullSchema; - EFI_STRING HiiString; - UINTN Size; - - 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; - } - - RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); - Value->Type =3D REDFISH_VALUE_TYPE_UNKNOWN; - FullSchema =3D NULL; - HiiString =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; - } - - 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; - } - - HiiString =3D HiiGetRedfishString (TargetStatement->ParentForm->Pare= ntFormset->HiiHandle, FullSchema, StringId); - if (HiiString =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, Can not find string ID: 0x%x with %a\n",= __FUNCTION__, StringId, FullSchema)); - Status =3D EFI_NOT_FOUND; - goto RELEASE_RESOURCE; - } - - Size =3D StrLen (HiiString) + 1; - Value->Value.Buffer =3D AllocatePool (Size); - if (Value->Value.Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto RELEASE_RESOURCE; - } - - UnicodeStrToAsciiStrS (HiiString, Value->Value.Buffer, Size); - 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 AllocateCopyPool (StrSize ((CHAR16 *)TargetS= tatement->HiiStatement->Value.Buffer), TargetStatement->HiiStatement->Value= .Buffer); - if (Value->Value.Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto RELEASE_RESOURCE; - } - 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; - 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; - } - -RELEASE_RESOURCE: - - if (FullSchema !=3D NULL) { - FreePool (FullSchema); - } - - if (HiiString !=3D NULL) { - FreePool (HiiString); - } - - return Status; -} - -/** - Function to save question value into HII database. - - @param[in] HiiFormset HII form-set instance - @param[in] HiiForm HII form instance - @param[in] HiiStatement HII statement that keeps new value. - @param[in] Value New value to applyu. - - @retval EFI_SUCCESS HII value is returned successfully. - @retval Others Errors occur - -**/ -EFI_STATUS -RedfishPlatformConfigSaveQuestionValue ( - IN HII_FORMSET *HiiFormset, - IN HII_FORM *HiiForm, - IN HII_STATEMENT *HiiStatement, - IN HII_STATEMENT_VALUE *Value - ) -{ - EFI_STATUS Status; - - if (HiiFormset =3D=3D NULL || HiiForm =3D=3D NULL || HiiStatement =3D=3D= NULL || Value =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - Status =3D SetQuestionValue ( - HiiFormset, - HiiForm, - HiiStatement, - Value - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to set question value: %r\n", __FUNCT= ION__, Status)); - return Status; - } - - Status =3D SubmitForm (HiiFormset, HiiForm); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to submit form: %r\n", __FUNCTION__, = Status)); - return Status; - } - - return EFI_SUCCESS; -} - -/** - Common implementation to set statement private instance. - - @param[in] RedfishPlatformConfigPrivate Private instance. - @param[in] Schema Redfish schema string. - @param[in] ConfigureLang Configure language that refe= rs to this statement. - @param[in] Statement Statement instance - - @retval EFI_SUCCESS HII value is returned successfully. - @retval Others Errors occur - -**/ -EFI_STATUS -RedfishPlatformConfigSetStatementCommon ( - IN REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate, - IN CHAR8 *Schema, - IN EFI_STRING ConfigureLang, - IN HII_STATEMENT_VALUE *StatementValue - ) -{ - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement; - EFI_STRING TempBuffer; - - if (RedfishPlatformConfigPrivate =3D=3D NULL || IS_EMPTY_STRING (Schema)= || IS_EMPTY_STRING (ConfigureLang) || StatementValue =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - TempBuffer =3D NULL; - - Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status)); - return Status; - } - - TargetStatement =3D GetStatementPrivateByConfigureLang (&RedfishPlatform= ConfigPrivate->FormsetList, Schema, ConfigureLang); - if (TargetStatement =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, No match HII statement is found by the given= %s in schema %a\n", __FUNCTION__, ConfigureLang, Schema)); - return EFI_NOT_FOUND; - } - - if (StatementValue->Type !=3D TargetStatement->HiiStatement->Value.Type)= { - // - // We treat one-of type as string in Redfish. But one-of statement is = not - // in string format from HII point of view. Do a patch here. - // - if (TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_ONE_OF_OP &&= StatementValue->Type =3D=3D EFI_IFR_TYPE_STRING) { - TempBuffer =3D AllocatePool (StatementValue->BufferLen * sizeof (CHA= R16)); - if (TempBuffer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - AsciiStrToUnicodeStrS (StatementValue->Buffer, TempBuffer, Statement= Value->BufferLen); - FreePool (StatementValue->Buffer); - StatementValue->Buffer =3D NULL; - StatementValue->BufferLen =3D 0; - - Status =3D HiiStringToOneOfOptionValue (TargetStatement, Schema, Tem= pBuffer, StatementValue); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to find option value by the given= %s\n", __FUNCTION__, TempBuffer)); - FreePool (TempBuffer); - return EFI_NOT_FOUND; - } - - FreePool (TempBuffer); - } else if (TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_NUMER= IC_OP && StatementValue->Type =3D=3D EFI_IFR_TYPE_NUM_SIZE_64) { - // - // Redfish only has numeric value type and it does not care about th= e value size. - // Do a patch here so we have proper value size applied. - // - StatementValue->Type =3D TargetStatement->HiiStatement->Value.Type; - } else { - DEBUG ((DEBUG_ERROR, "%a, catch value type mismatch! input type: 0x%= x but target value type: 0x%x\n", __FUNCTION__, StatementValue->Type, Targe= tStatement->HiiStatement->Value.Type)); - ASSERT (FALSE); - } - } - - Status =3D RedfishPlatformConfigSaveQuestionValue ( - TargetStatement->ParentForm->ParentFormset->HiiFormSet, - TargetStatement->ParentForm->HiiForm, - TargetStatement->HiiStatement, - StatementValue - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to save question value: %r\n", __FUNC= TION__, Status)); - return Status; - } - - return EFI_SUCCESS; -} - -/** - Set Redfish 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] Value The value to set. - - @retval EFI_SUCCESS Value is returned successfully. - @retval Others Some error happened. - -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigProtocolSetValue ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING ConfigureLang, - IN EDKII_REDFISH_VALUE Value - ) -{ - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate; - CHAR8 *FullSchema; - HII_STATEMENT_VALUE NewValue; - - if (This =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Ver= sion) || IS_EMPTY_STRING (ConfigureLang)) { - return EFI_INVALID_PARAMETER; - } - - if (Value.Type =3D=3D REDFISH_VALUE_TYPE_UNKNOWN || Value.Type >=3D REDF= ISH_VALUE_TYPE_MAX) { - return EFI_INVALID_PARAMETER; - } - - RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); - FullSchema =3D NULL; - - FullSchema =3D GetFullSchemaString (Schema, Version); - if (FullSchema =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - ZeroMem (&NewValue, sizeof (HII_STATEMENT_VALUE)); - - switch (Value.Type) { - case REDFISH_VALUE_TYPE_INTEGER: - case REDFISH_VALUE_TYPE_BOOLEAN: - Status =3D RedfishNumericToHiiValue (&Value, &NewValue); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to convert Redfish value to Hii v= alue: %r\n", __FUNCTION__, Status)); - goto RELEASE_RESOURCE; - } - break; - case REDFISH_VALUE_TYPE_STRING: - NewValue.Type =3D EFI_IFR_TYPE_STRING; - NewValue.BufferLen =3D (UINT16)AsciiStrSize (Value.Value.Buffer); - NewValue.Buffer =3D AllocateCopyPool (NewValue.BufferLen, Value.Valu= e.Buffer); - if (NewValue.Buffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto RELEASE_RESOURCE; - } - break; - default: - ASSERT (FALSE); - break; - } - - Status =3D RedfishPlatformConfigSetStatementCommon (RedfishPlatformConfi= gPrivate, FullSchema, ConfigureLang, &NewValue); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to set value to statement: %r\n", __F= UNCTION__, Status)); - } - -RELEASE_RESOURCE: - - if (FullSchema !=3D NULL) { - FreePool (FullSchema); - } - - return Status; -} - -/** - Get the list of Configure Language from platform configuration by the gi= ven Schema and Pattern. - - @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] Pattern The target Configure Language pattern. - @param[out] ConfigureLangList The list of Configure Language. - @param[out] Count The number of Configure Language in Con= figureLangList. - - @retval EFI_SUCCESS ConfigureLangList is returned successfu= lly. - @retval Others Some error happened. - -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigProtocolGetConfigureLang ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING Pattern, - OUT EFI_STRING **ConfigureLangList, - OUT UINTN *Count - ) -{ - REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPr= ivate; - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST StatementList; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef; - LIST_ENTRY *NextLink; - EFI_STRING TmpString; - EFI_STRING *TmpConfigureLangList; - UINTN Index; - CHAR8 *FullSchema; - - if (This =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Ver= sion) || Count =3D=3D NULL || ConfigureLangList =3D=3D NULL || IS_EMPTY_STR= ING (Pattern)) { - return EFI_INVALID_PARAMETER; - } - - *Count =3D 0; - *ConfigureLangList =3D NULL; - FullSchema =3D NULL; - RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); - - Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status)); - return Status; - } - - FullSchema =3D GetFullSchemaString (Schema, Version); - if (FullSchema =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status =3D GetStatementPrivateByConfigureLangRegex ( - RedfishPlatformConfigPrivate->RegularExpressionProtocol, - &RedfishPlatformConfigPrivate->FormsetList, - FullSchema, - Pattern, - &StatementList - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, GetStatementPrivateByConfigureLangRegex fail= ure: %r\n", __FUNCTION__, Status)); - goto RELEASE_RESOURCE; - } - - if (!IsListEmpty (&StatementList.StatementList)) { - - TmpConfigureLangList =3D AllocateZeroPool (sizeof (CHAR16 *) * Stateme= ntList.Count); - if (TmpConfigureLangList =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto RELEASE_RESOURCE; - } - - Index =3D 0; - NextLink =3D GetFirstNode (&StatementList.StatementList); - while (!IsNull (&StatementList.StatementList, NextLink)) { - StatementRef =3D REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK (Ne= xtLink); - NextLink =3D GetNextNode (&StatementList.StatementList, NextLink); - - ASSERT (StatementRef->Statement->Description !=3D 0); - if (StatementRef->Statement->Description !=3D 0) { - TmpString =3D HiiGetRedfishString (StatementRef->Statement->Parent= Form->ParentFormset->HiiHandle, FullSchema, StatementRef->Statement->Descri= ption); - ASSERT (TmpString !=3D NULL); - if (TmpString !=3D NULL) { - TmpConfigureLangList[Index] =3D AllocateCopyPool (StrSize (TmpSt= ring), TmpString); - ASSERT (TmpConfigureLangList[Index] !=3D NULL); - FreePool (TmpString); - ++Index; - } - } - } - } - - *Count =3D StatementList.Count; - *ConfigureLangList =3D TmpConfigureLangList; - -RELEASE_RESOURCE: - - if (FullSchema !=3D NULL) { - FreePool (FullSchema); - } - - ReleaseStatementList (&StatementList); - - return Status; -} - - -/** - Get the list of supported Redfish schema from paltform configuration on = give HII handle. - - @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance. - @param[in] HiiHandle The target handle to search. If handle = is NULL, - this function return all schema from HI= I database. - @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'. - The SupportedSchema is allocated by the= callee. It's caller's - responsibility to free this buffer usin= g FreePool(). - - @retval EFI_SUCCESS Schema is returned successfully. - @retval Others Some error happened. - -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigProtocolGetSupportedSchema ( - IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This, - IN EFI_HII_HANDLE HiiHandle, OPTIONAL - OUT CHAR8 **SupportedSchema - ) -{ - REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate; - EFI_STATUS Status; - LIST_ENTRY *HiiFormsetLink; - LIST_ENTRY *HiiFormsetNextLink; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate; - UINTN Index; - UINTN StringSize; - CHAR8 *StringBuffer; - UINTN StringIndex; - - if (This =3D=3D NULL || SupportedSchema =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - *SupportedSchema =3D NULL; - - RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This); - - Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status)); - return Status; - } - - if (IsListEmpty (&RedfishPlatformConfigPrivate->FormsetList)) { - return EFI_NOT_FOUND; - } - - // - // Calculate for string buffer size. - // - StringSize =3D 0; - HiiFormsetLink =3D GetFirstNode (&RedfishPlatformConfigPrivate->FormsetL= ist); - while (!IsNull (&RedfishPlatformConfigPrivate->FormsetList, HiiFormsetLi= nk)) { - HiiFormsetNextLink =3D GetNextNode (&RedfishPlatformConfigPrivate->For= msetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - if (HiiHandle !=3D NULL && HiiHandle !=3D HiiFormsetPrivate->HiiHandle= ) { - HiiFormsetLink =3D HiiFormsetNextLink; - continue; - } - - if (HiiFormsetPrivate->SupportedSchema.Count > 0) { - for (Index =3D 0; Index < HiiFormsetPrivate->SupportedSchema.Count; = Index++) { - StringSize +=3D AsciiStrSize (HiiFormsetPrivate->SupportedSchema.S= chemaList[Index]); - } - } - - HiiFormsetLink =3D HiiFormsetNextLink; - } - - if (StringSize =3D=3D 0) { - return EFI_NOT_FOUND; - } - - StringBuffer =3D AllocatePool (StringSize); - if (StringBuffer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - StringIndex =3D 0; - HiiFormsetLink =3D GetFirstNode (&RedfishPlatformConfigPrivate->FormsetL= ist); - while (!IsNull (&RedfishPlatformConfigPrivate->FormsetList, HiiFormsetLi= nk)) { - HiiFormsetNextLink =3D GetNextNode (&RedfishPlatformConfigPrivate->For= msetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - if (HiiHandle !=3D NULL && HiiHandle !=3D HiiFormsetPrivate->HiiHandle= ) { - HiiFormsetLink =3D HiiFormsetNextLink; - continue; - } - - if (HiiFormsetPrivate->SupportedSchema.Count > 0) { - for (Index =3D 0; Index < HiiFormsetPrivate->SupportedSchema.Count; = Index++) { - AsciiStrCpyS (&StringBuffer[StringIndex], (StringSize - StringInde= x), HiiFormsetPrivate->SupportedSchema.SchemaList[Index]); - StringIndex +=3D AsciiStrLen (HiiFormsetPrivate->SupportedSchema.S= chemaList[Index]); - StringBuffer[StringIndex] =3D ';'; - ++StringIndex; - } - } - - HiiFormsetLink =3D HiiFormsetNextLink; - } - - StringBuffer[--StringIndex] =3D '\0'; - - *SupportedSchema =3D StringBuffer; - - return EFI_SUCCESS; -} - -/** - Functions which are registered to receive notification of - database events have this prototype. The actual event is encoded - in NotifyType. The following table describes how PackageType, - PackageGuid, Handle, and Package are used for each of the - notification types. - - @param[in] PackageType Package type of the notification. - @param[in] PackageGuid If PackageType is - EFI_HII_PACKAGE_TYPE_GUID, then this is - the pointer to the GUID from the Guid - field of EFI_HII_PACKAGE_GUID_HEADER. - Otherwise, it must be NULL. - @param[in] Package Points to the package referred to by the - notification Handle The handle of the package - list which contains the specified package. - @param[in] Handle The HII handle. - @param[in] NotifyType The type of change concerning the - database. See - EFI_HII_DATABASE_NOTIFY_TYPE. - -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigFormUpdateNotify ( - IN UINT8 PackageType, - IN CONST EFI_GUID *PackageGuid, - IN CONST EFI_HII_PACKAGE_HEADER *Package, - IN EFI_HII_HANDLE Handle, - IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType - ) -{ - EFI_STATUS Status; - - if (NotifyType =3D=3D EFI_HII_DATABASE_NOTIFY_NEW_PACK || NotifyType =3D= =3D EFI_HII_DATABASE_NOTIFY_ADD_PACK) { - // - // HII formset on this handle is updated by driver during run-time. Th= e formset needs to be reloaded. - // - Status =3D NotifyFormsetUpdate (Handle, &mRedfishPlatformConfigPrivate= ->PendingList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to notify updated formset of HII ha= ndle: 0x%x\n", __FUNCTION__, Handle)); - return Status; - } - } else if (NotifyType =3D=3D EFI_HII_DATABASE_NOTIFY_REMOVE_PACK) { - // - // HII resource is removed. The formset is no longer exist. - // - Status =3D NotifyFormsetDeleted (Handle, &mRedfishPlatformConfigPrivat= e->PendingList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to notify deleted formset of HII ha= ndle: 0x%x\n", __FUNCTION__, Handle)); - return Status; - } - } - - return EFI_SUCCESS; -} - -/** - This is a EFI_HII_STRING_PROTOCOL notification event handler. - - Install HII package notification. - - @param[in] Event Event whose notification function is being invoked. - @param[in] Context Pointer to the notification function's context. - -**/ -VOID -EFIAPI -HiiStringProtocolInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - // - // Locate HII database protocol. - // - Status =3D gBS->LocateProtocol ( - &gEfiHiiStringProtocolGuid, - NULL, - (VOID **)&mRedfishPlatformConfigPrivate->HiiString - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, locate EFI_HII_STRING_PROTOCOL failure: %r\n= ", __FUNCTION__, Status)); - return; - } - - gBS->CloseEvent (Event); - mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent =3D NULL; -} - -/** - This is a EFI_HII_DATABASE_PROTOCOL notification event handler. - - Install HII package notification. - - @param[in] Event Event whose notification function is being invoked. - @param[in] Context Pointer to the notification function's context. - -**/ -VOID -EFIAPI -HiiDatabaseProtocolInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - // - // Locate HII database protocol. - // - Status =3D gBS->LocateProtocol ( - &gEfiHiiDatabaseProtocolGuid, - NULL, - (VOID **)&mRedfishPlatformConfigPrivate->HiiDatabase - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, locate EFI_HII_DATABASE_PROTOCOL failure: %r= \n", __FUNCTION__, Status)); - return; - } - - // - // Register package notification when new form package is installed. - // - Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->RegisterPackageNo= tify ( - mRedfishPlatformConfigPrivate= ->HiiDatabase, - EFI_HII_PACKAGE_FORMS, - NULL, - RedfishPlatformConfigFormUpda= teNotify, - EFI_HII_DATABASE_NOTIFY_NEW_P= ACK, - &mRedfishPlatformConfigPrivat= e->NotifyHandle - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, RegisterPackageNotify for EFI_HII_DATABASE_N= OTIFY_NEW_PACK failure: %r\n", __FUNCTION__, Status)); - } - - // - // Register package notification when new form package is updated. - // - Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->RegisterPackageNo= tify ( - mRedfishPlatformConfigPrivate= ->HiiDatabase, - EFI_HII_PACKAGE_FORMS, - NULL, - RedfishPlatformConfigFormUpda= teNotify, - EFI_HII_DATABASE_NOTIFY_ADD_P= ACK, - &mRedfishPlatformConfigPrivat= e->NotifyHandle - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, RegisterPackageNotify for EFI_HII_DATABASE_N= OTIFY_NEW_PACK failure: %r\n", __FUNCTION__, Status)); - } - -#if REDFISH_PLATFORM_CONFIG_DELETE_EXPIRED_FORMSET - // - // Register package notification when new form package is removed. - // - Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->RegisterPackageNo= tify ( - mRedfishPlatformConfigPrivate= ->HiiDatabase, - EFI_HII_PACKAGE_FORMS, - NULL, - RedfishPlatformConfigFormUpda= teNotify, - EFI_HII_DATABASE_NOTIFY_REMOV= E_PACK, - &mRedfishPlatformConfigPrivat= e->NotifyHandle - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, RegisterPackageNotify for EFI_HII_DATABASE_N= OTIFY_NEW_PACK failure: %r\n", __FUNCTION__, Status)); - } -#endif - - gBS->CloseEvent (Event); - mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent =3D NULL; - -} - -/** - This is a EFI_REGULAR_EXPRESSION_PROTOCOL notification event handler. - - @param[in] Event Event whose notification function is being invoked. - @param[in] Context Pointer to the notification function's context. - -**/ -VOID -EFIAPI -RegexProtocolInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - // - // Locate regular expression protocol. - // - Status =3D gBS->LocateProtocol ( - &gEfiRegularExpressionProtocolGuid, - NULL, - (VOID **)&mRedfishPlatformConfigPrivate->RegularExpressi= onProtocol - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, locate EFI_REGULAR_EXPRESSION_PROTOCOL failu= re: %r\n", __FUNCTION__, Status)); - return; - } - - gBS->CloseEvent (Event); - mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent =3D NULL; - -} - -/** - Unloads an image. - - @param ImageHandle Handle that identifies the image to be unl= oaded. - - @retval EFI_SUCCESS The image has been unloaded. - @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. - -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigDxeUnload ( - IN EFI_HANDLE ImageHandle - ) -{ - EFI_STATUS Status; - - if (mRedfishPlatformConfigPrivate !=3D NULL) { - Status =3D gBS->UninstallProtocolInterface ( - mRedfishPlatformConfigPrivate->ImageHandle, - &gEdkIIRedfishPlatformConfigProtocolGuid, - (VOID*)&mRedfishPlatformConfigPrivate->Protocol - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, can not uninstall gEdkIIRedfishPlatformCon= figProtocolGuid: %r\n", __FUNCTION__, Status)); - ASSERT (FALSE); - } - - // - // Close events - // - if (mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent !=3D NULL= ) { - gBS->CloseEvent (mRedfishPlatformConfigPrivate->HiiDbNotify.Protocol= Event); - } - if (mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent !=3D = NULL) { - gBS->CloseEvent (mRedfishPlatformConfigPrivate->HiiStringNotify.Prot= ocolEvent); - } - if (mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent !=3D NULL= ) { - gBS->CloseEvent (mRedfishPlatformConfigPrivate->RegexNotify.Protocol= Event); - } - - // - // Unregister package notification. - // - if (mRedfishPlatformConfigPrivate->NotifyHandle !=3D NULL) { - mRedfishPlatformConfigPrivate->HiiDatabase->UnregisterPackageNotify ( - mRedfishPlatformConfigPrivate->H= iiDatabase, - mRedfishPlatformConfigPrivate->N= otifyHandle - ); - } - - ReleaseFormsetList (&mRedfishPlatformConfigPrivate->FormsetList); - FreePool (mRedfishPlatformConfigPrivate); - mRedfishPlatformConfigPrivate =3D NULL; - } - - return EFI_SUCCESS; -} - - -/** - This is the declaration of an EFI image entry point. This entry point is - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers includ= ing - both device drivers and bus drivers. - - @param ImageHandle The firmware allocated handle for the UEFI= image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval Others An unexpected error occurred. -**/ -EFI_STATUS -EFIAPI -RedfishPlatformConfigDxeEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - mRedfishPlatformConfigPrivate =3D (REDFISH_PLATFORM_CONFIG_PRIVATE *)All= ocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_PRIVATE)); - if (mRedfishPlatformConfigPrivate =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, can not allocate pool for REDFISH_PLATFORM_C= ONFIG_PRIVATE\n", __FUNCTION__)); - ASSERT (FALSE); - return EFI_OUT_OF_RESOURCES; - } - - // - // 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.GetSupportedSchema =3D RedfishPl= atformConfigProtocolGetSupportedSchema; - - InitializeListHead (&mRedfishPlatformConfigPrivate->FormsetList); - InitializeListHead (&mRedfishPlatformConfigPrivate->PendingList); - - Status =3D gBS->InstallProtocolInterface ( - &ImageHandle, - &gEdkIIRedfishPlatformConfigProtocolGuid, - EFI_NATIVE_INTERFACE, - (VOID*)&mRedfishPlatformConfigPrivate->Protocol - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, can not install gEdkIIRedfishPlatformConfigP= rotocolGuid: %r\n", __FUNCTION__, Status)); - ASSERT (FALSE); - } - - // - // Install protocol notification if HII database protocol is installed. - // - mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent =3D EfiCreatePr= otocolNotifyEvent ( - &gEfiHiiData= baseProtocolGuid, - TPL_CALLBACK, - HiiDatabaseP= rotocolInstalled, - NULL, - &mRedfishPla= tformConfigPrivate->HiiDbNotify.Registration - ); - if (mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent =3D=3D NULL= ) { - DEBUG ((DEBUG_ERROR, "%a, failed to create protocol notification for g= EfiHiiDatabaseProtocolGuid\n", __FUNCTION__)); - ASSERT (FALSE); - } - - // - // Install protocol notification if HII string protocol is installed. - // - mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent =3D EfiCrea= teProtocolNotifyEvent ( - &gEfiHii= StringProtocolGuid, - TPL_CALL= BACK, - HiiStrin= gProtocolInstalled, - NULL, - &mRedfis= hPlatformConfigPrivate->HiiStringNotify.Registration - ); - if (mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent =3D=3D = NULL) { - DEBUG ((DEBUG_ERROR, "%a, failed to create protocol notification for g= EfiHiiStringProtocolGuid\n", __FUNCTION__)); - ASSERT (FALSE); - } - - // - // Install protocol notification if regular expression protocol is insta= lled. - // - mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent =3D EfiCreatePr= otocolNotifyEvent ( - &gEfiRegular= ExpressionProtocolGuid, - TPL_CALLBACK, - RegexProtoco= lInstalled, - NULL, - &mRedfishPla= tformConfigPrivate->RegexNotify.Registration - ); - if (mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent =3D=3D NULL= ) { - DEBUG ((DEBUG_ERROR, "%a, failed to create protocol notification for g= EfiRegularExpressionProtocolGuid\n", __FUNCTION__)); - ASSERT (FALSE); - } - - return EFI_SUCCESS; -} +/** @file=0D +=0D + The implementation of EDKII Redfidh Platform Config Protocol.=0D +=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include "RedfishPlatformConfigDxe.h"=0D +#include "RedfishPlatformConfigImpl.h"=0D +=0D +REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate =3D NULL;=0D +=0D +=0D +/**=0D + Zero extend integer/boolean to UINT64 for comparing.=0D +=0D + @param Value HII Value to be converted.=0D +=0D +**/=0D +UINT64=0D +ExtendHiiValueToU64 (=0D + IN HII_STATEMENT_VALUE *Value=0D + )=0D +{=0D + UINT64 Temp;=0D +=0D + Temp =3D 0;=0D + switch (Value->Type) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + Temp =3D Value->Value.u8;=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + Temp =3D Value->Value.u16;=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + Temp =3D Value->Value.u32;=0D + break;=0D +=0D + case EFI_IFR_TYPE_BOOLEAN:=0D + Temp =3D Value->Value.b;=0D + break;=0D +=0D + case EFI_IFR_TYPE_TIME:=0D + case EFI_IFR_TYPE_DATE:=0D + default:=0D + break;=0D + }=0D +=0D + return Temp;=0D +}=0D +=0D +/**=0D + Set value of a data element in an Array by its Index in ordered list buf= fer.=0D +=0D + @param Array The data array.=0D + @param Type Type of the data in this array.=0D + @param Index Zero based index for data in this array.= =0D + @param Value The value to be set.=0D +=0D +**/=0D +VOID=0D +OrderedListSetArrayData (=0D + IN VOID *Array,=0D + IN UINT8 Type,=0D + IN UINTN Index,=0D + IN UINT64 Value=0D + )=0D +{=0D +=0D + ASSERT (Array !=3D NULL);=0D +=0D + switch (Type) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + *(((UINT8 *) Array) + Index) =3D (UINT8) Value;=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + *(((UINT16 *) Array) + Index) =3D (UINT16) Value;=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + *(((UINT32 *) Array) + Index) =3D (UINT32) Value;=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_64:=0D + *(((UINT64 *) Array) + Index) =3D (UINT64) Value;=0D + break;=0D +=0D + default:=0D + break;=0D + }=0D +}=0D +=0D +=0D +/**=0D + Return data element in an Array by its Index in ordered list array buffe= r.=0D +=0D + @param Array The data array.=0D + @param Type Type of the data in this array.=0D + @param Index Zero based index for data in this array.= =0D +=0D + @retval Value The data to be returned=0D +=0D +**/=0D +UINT64=0D +OrderedListGetArrayData (=0D + IN VOID *Array,=0D + IN UINT8 Type,=0D + IN UINTN Index=0D + )=0D +{=0D + UINT64 Data;=0D +=0D + ASSERT (Array !=3D NULL);=0D +=0D + Data =3D 0;=0D + switch (Type) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + Data =3D (UINT64) *(((UINT8 *) Array) + Index);=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + Data =3D (UINT64) *(((UINT16 *) Array) + Index);=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + Data =3D (UINT64) *(((UINT32 *) Array) + Index);=0D + break;=0D +=0D + case EFI_IFR_TYPE_NUM_SIZE_64:=0D + Data =3D (UINT64) *(((UINT64 *) Array) + Index);=0D + break;=0D +=0D + default:=0D + break;=0D + }=0D +=0D + return Data;=0D +}=0D +=0D +=0D +/**=0D + Find string ID of option if its value equals to given value.=0D +=0D + @param[in] HiiStatement Statement to search.=0D + @param[in] Value Target value.=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STRING_ID=0D +OrderedListOptionValueToStringId (=0D + IN HII_STATEMENT *HiiStatement,=0D + IN UINT64 Value=0D + )=0D +{=0D + LIST_ENTRY *Link;=0D + HII_QUESTION_OPTION *Option;=0D + BOOLEAN Found;=0D + UINT64 CurrentValue;=0D +=0D + if (HiiStatement =3D=3D NULL) {=0D + return 0;=0D + }=0D +=0D + if (HiiStatement->Operand !=3D EFI_IFR_ORDERED_LIST_OP) {=0D + return 0;=0D + }=0D +=0D + if (IsListEmpty (&HiiStatement->OptionListHead)) {=0D + return 0;=0D + }=0D +=0D + Found =3D FALSE;=0D + Link =3D GetFirstNode (&HiiStatement->OptionListHead);=0D + while (!IsNull (&HiiStatement->OptionListHead, Link)) {=0D + Option =3D HII_QUESTION_OPTION_FROM_LINK (Link);=0D +=0D + CurrentValue =3D ExtendHiiValueToU64 (&Option->Value);=0D + if (Value =3D=3D CurrentValue) {=0D + return Option->Text;=0D + }=0D +=0D + Link =3D GetNextNode (&HiiStatement->OptionListHead, Link);=0D + }=0D +=0D + return 0;=0D +}=0D +=0D +/**=0D + Compare two value in HII statement format.=0D +=0D + @param[in] Value1 Firt value to compare.=0D + @param[in] Value2 Second value to be compared.=0D +=0D + @retval UINTN 0 is retuned when two values are equal.=0D + 1 is returned when first value is greater than sec= ond value.=0D + -1 is returned when second value is greater than f= irst value.=0D +=0D +**/=0D +UINTN=0D +CompareHiiStatementValue (=0D + IN HII_STATEMENT_VALUE *Value1,=0D + IN HII_STATEMENT_VALUE *Value2=0D + )=0D +{=0D + INTN Result;=0D + UINT64 Data1;=0D + UINT64 Data2;=0D +=0D + if (Value1 =3D=3D NULL || Value2 =3D=3D NULL) {=0D + return 0xFF;=0D + }=0D +=0D + switch (Value1->Type) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + Data1 =3D Value1->Value.u8;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + Data1 =3D Value1->Value.u16;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + Data1 =3D Value1->Value.u32;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_64:=0D + Data1 =3D Value1->Value.u64;=0D + break;=0D + case EFI_IFR_TYPE_BOOLEAN:=0D + Data1 =3D (Value1->Value.b ? 1 : 0);=0D + break;=0D + default:=0D + return 0xFF;=0D + }=0D +=0D + switch (Value2->Type) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + Data2 =3D Value2->Value.u8;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + Data2 =3D Value2->Value.u16;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + Data2 =3D Value2->Value.u32;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_64:=0D + Data2 =3D Value2->Value.u64;=0D + break;=0D + case EFI_IFR_TYPE_BOOLEAN:=0D + Data2 =3D (Value2->Value.b ? 1 : 0);=0D + break;=0D + default:=0D + return 0xFF;=0D + }=0D +=0D + Result =3D (Data1 =3D=3D Data2 ? 0 : (Data1 > Data2 ? 1 : -1));=0D +=0D + return Result;=0D +}=0D +=0D +/**=0D + Convert HII value to the string in HII one-of opcode.=0D +=0D + @param[in] Statement Statement private instance=0D +=0D + @retval EFI_STRING_ID The string ID in HII database.=0D + 0 is returned when something goes wrong.=0D +=0D +**/=0D +EFI_STRING_ID=0D +HiiValueToOneOfOptionStringId (=0D + IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement=0D + )=0D +{=0D + LIST_ENTRY *Link;=0D + HII_QUESTION_OPTION *Option;=0D +=0D + if (Statement->HiiStatement->Operand !=3D EFI_IFR_ONE_OF_OP) {=0D + return 0;=0D + }=0D +=0D + if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {=0D + return 0;=0D + }=0D +=0D + Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead);=0D + while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {=0D + Option =3D HII_QUESTION_OPTION_FROM_LINK (Link);=0D +=0D + if (CompareHiiStatementValue (&Statement->HiiStatement->Value, &Option= ->Value) =3D=3D 0) {=0D + return Option->Text;=0D + }=0D +=0D + Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link);= =0D + }=0D +=0D + return 0;=0D +}=0D +=0D +/**=0D + Convert HII string to the value in HII one-of opcode.=0D +=0D + @param[in] Statement Statement private instance=0D + @param[in] Schema Schema string=0D + @param[in] HiiString Input string=0D + @param[out] Value Value returned=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +HiiStringToOneOfOptionValue (=0D + IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING HiiString,=0D + OUT HII_STATEMENT_VALUE *Value=0D + )=0D +{=0D + LIST_ENTRY *Link;=0D + HII_QUESTION_OPTION *Option;=0D + EFI_STRING TmpString;=0D + BOOLEAN Found;=0D +=0D + if (Statement =3D=3D NULL || IS_EMPTY_STRING (HiiString) || Value =3D=3D= NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (Statement->HiiStatement->Operand !=3D EFI_IFR_ONE_OF_OP) {=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + Found =3D FALSE;=0D + Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead);=0D + while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {=0D + Option =3D HII_QUESTION_OPTION_FROM_LINK (Link);=0D +=0D + TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentFormse= t->HiiHandle, Schema, Option->Text);=0D + if (TmpString !=3D NULL) {=0D + if (StrCmp (TmpString, HiiString) =3D=3D 0) {=0D + CopyMem (Value, &Option->Value, sizeof (HII_STATEMENT_VALUE));=0D + Found =3D TRUE;=0D + }=0D + FreePool (TmpString);=0D + }=0D +=0D + if (Found) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link);= =0D + }=0D +=0D + return EFI_NOT_FOUND;=0D +}=0D +=0D +/**=0D + Convert HII value to numeric value in Redfish format.=0D +=0D + @param[in] Value Value to be converted.=0D + @param[out] RedfishValue Value in Redfish format.=0D +=0D + @retval EFI_SUCCESS Redfish value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +HiiValueToRedfishNumeric (=0D + IN HII_STATEMENT_VALUE *Value,=0D + OUT EDKII_REDFISH_VALUE *RedfishValue=0D + )=0D +{=0D + if (Value =3D=3D NULL || RedfishValue =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + switch (Value->Type) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER;=0D + RedfishValue->Value.Integer =3D (INT64)Value->Value.u8;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER;=0D + RedfishValue->Value.Integer =3D (INT64)Value->Value.u16;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER;=0D + RedfishValue->Value.Integer =3D (INT64)Value->Value.u32;=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_64:=0D + RedfishValue->Type =3D REDFISH_VALUE_TYPE_INTEGER;=0D + RedfishValue->Value.Integer =3D (INT64)Value->Value.u64;=0D + break;=0D + case EFI_IFR_TYPE_BOOLEAN:=0D + RedfishValue->Type =3D REDFISH_VALUE_TYPE_BOOLEAN;=0D + RedfishValue->Value.Boolean =3D Value->Value.b;=0D + break;=0D + default:=0D + RedfishValue->Type =3D REDFISH_VALUE_TYPE_UNKNOWN;=0D + break;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Convert numeric value in Redfish format to HII value.=0D +=0D + @param[in] RedfishValue Value in Redfish format to be converted.=0D + @param[out] Value HII value returned.=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +RedfishNumericToHiiValue (=0D + IN EDKII_REDFISH_VALUE *RedfishValue,=0D + OUT HII_STATEMENT_VALUE *Value=0D + )=0D +{=0D + if (Value =3D=3D NULL || RedfishValue =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + switch (RedfishValue->Type) {=0D + case REDFISH_VALUE_TYPE_INTEGER:=0D + Value->Type =3D EFI_IFR_TYPE_NUM_SIZE_64;=0D + Value->Value.u64 =3D (UINT64)RedfishValue->Value.Integer;=0D + break;=0D + case REDFISH_VALUE_TYPE_BOOLEAN:=0D + Value->Type =3D EFI_IFR_TYPE_BOOLEAN;=0D + Value->Value.b =3D RedfishValue->Value.Boolean;=0D + break;=0D + default:=0D + Value->Type =3D EFI_IFR_TYPE_UNDEFINED;=0D + break;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Dump the value in ordered list buffer.=0D +=0D + @param[in] OrderedListStatement Ordered list statement.=0D +=0D +**/=0D +VOID=0D +DumpOrderedListValue (=0D + IN HII_STATEMENT *OrderedListStatement=0D + )=0D +{=0D + UINT8 *Value8;=0D + UINT16 *Value16;=0D + UINT32 *Value32;=0D + UINT64 *Value64;=0D + UINTN Count;=0D + UINTN Index;=0D +=0D + if (OrderedListStatement =3D=3D NULL || OrderedListStatement->Operand != =3D EFI_IFR_ORDERED_LIST_OP) {=0D + return;=0D + }=0D +=0D + DEBUG ((DEBUG_ERROR, "Value.Type=3D 0x%x\n", OrderedListStatement->Value= .Type));=0D + DEBUG ((DEBUG_ERROR, "Value.BufferValueType=3D 0x%x\n", OrderedListState= ment->Value.BufferValueType));=0D + DEBUG ((DEBUG_ERROR, "Value.BufferLen=3D 0x%x\n", OrderedListStatement->= Value.BufferLen));=0D + DEBUG ((DEBUG_ERROR, "Value.Buffer=3D 0x%x\n", OrderedListStatement->Val= ue.Buffer));=0D + DEBUG ((DEBUG_ERROR, "Value.MaxContainers=3D 0x%x\n", OrderedListStateme= nt->ExtraData.OrderListData.MaxContainers));=0D + DEBUG ((DEBUG_ERROR, "StorageWidth=3D 0x%x\n", OrderedListStatement->Sto= rageWidth));=0D +=0D + if (OrderedListStatement->Value.Buffer =3D=3D NULL) {=0D + return;=0D + }=0D +=0D + Value8 =3D NULL;=0D + Value16 =3D NULL;=0D + Value32 =3D NULL;=0D + Value64 =3D NULL;=0D + Count =3D 0;=0D +=0D + switch (OrderedListStatement->Value.BufferValueType) {=0D + case EFI_IFR_TYPE_NUM_SIZE_8:=0D + Value8 =3D (UINT8 *)OrderedListStatement->Value.Buffer;=0D + Count =3D OrderedListStatement->StorageWidth / sizeof (UINT8);=0D + for (Index =3D 0; Index < Count; Index++) {=0D + DEBUG ((DEBUG_ERROR, "%d ", Value8[Index]));=0D + }=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_16:=0D + Value16 =3D (UINT16 *)OrderedListStatement->Value.Buffer;=0D + Count =3D OrderedListStatement->StorageWidth / sizeof (UINT16);=0D + for (Index =3D 0; Index < Count; Index++) {=0D + DEBUG ((DEBUG_ERROR, "%d ", Value16[Index]));=0D + }=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_32:=0D + Value32 =3D (UINT32 *)OrderedListStatement->Value.Buffer;=0D + Count =3D OrderedListStatement->StorageWidth / sizeof (UINT32);=0D + for (Index =3D 0; Index < Count; Index++) {=0D + DEBUG ((DEBUG_ERROR, "%d ", Value32[Index]));=0D + }=0D + break;=0D + case EFI_IFR_TYPE_NUM_SIZE_64:=0D + Value64 =3D (UINT64 *)OrderedListStatement->Value.Buffer;=0D + Count =3D OrderedListStatement->StorageWidth / sizeof (UINT64);=0D + for (Index =3D 0; Index < Count; Index++) {=0D + DEBUG ((DEBUG_ERROR, "%d ", Value64[Index]));=0D + }=0D + break;=0D + default:=0D + Value8 =3D (UINT8 *)OrderedListStatement->Value.Buffer;=0D + Count =3D OrderedListStatement->StorageWidth / sizeof (UINT8);=0D + for (Index =3D 0; Index < Count; Index++) {=0D + DEBUG ((DEBUG_ERROR, "%d ", Value8[Index]));=0D + }=0D + break;=0D + }=0D +=0D + DEBUG ((DEBUG_ERROR, "\n"));=0D +}=0D +=0D +/**=0D + Convert HII value to the string in HII ordered list opcode. It's caller'= s=0D + responsibility to free returned buffer using FreePool().=0D +=0D + @param[in] Statement Statement private instance=0D + @param[out] ReturnSize The size of returned array=0D +=0D + @retval EFI_STRING_ID The string ID array for options in ordered lis= t.=0D +=0D +**/=0D +EFI_STRING_ID *=0D +HiiValueToOrderedListOptionStringId (=0D + IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement,=0D + OUT UINTN *ReturnSize=0D + )=0D +{=0D + LIST_ENTRY *Link;=0D + HII_QUESTION_OPTION *Option;=0D + UINTN OptionCount;=0D + EFI_STRING_ID *ReturnedArray;=0D + UINTN Index;=0D + UINT64 Value;=0D +=0D + if (Statement =3D=3D NULL || ReturnSize =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + *ReturnSize =3D 0;=0D +=0D + if (Statement->HiiStatement->Operand !=3D EFI_IFR_ORDERED_LIST_OP) {=0D + return NULL;=0D + }=0D +=0D + if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {=0D + return NULL;=0D + }=0D +=0D + DEBUG_CODE (=0D + DumpOrderedListValue (Statement->HiiStatement);=0D + );=0D +=0D + OptionCount =3D 0;=0D + Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead);=0D + while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {=0D + Option =3D HII_QUESTION_OPTION_FROM_LINK (Link);=0D +=0D + ++OptionCount;=0D +=0D + Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link);= =0D + }=0D +=0D + *ReturnSize =3D OptionCount;=0D + ReturnedArray =3D AllocatePool (sizeof (EFI_STRING_ID) * OptionCount);=0D + if (ReturnedArray =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__));=0D + *ReturnSize =3D 0;=0D + return NULL;=0D + }=0D +=0D + for (Index =3D 0; Index < OptionCount; Index++) {=0D + Value =3D OrderedListGetArrayData (Statement->HiiStatement->Value.Buff= er, Statement->HiiStatement->Value.BufferValueType, Index);=0D + ReturnedArray[Index] =3D OrderedListOptionValueToStringId (Statement->= HiiStatement, Value);=0D + }=0D +=0D + return ReturnedArray;=0D +}=0D +=0D +/**=0D + Convert HII string to the value in HII ordered list opcode.=0D +=0D + @param[in] Statement Statement private instance=0D + @param[in] Schema Schema string=0D + @param[in] HiiString Input string=0D + @param[out] Value Value returned=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +HiiStringToOrderedListOptionValue (=0D + IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING HiiString,=0D + OUT UINT64 *Value=0D + )=0D +{=0D + LIST_ENTRY *Link;=0D + HII_QUESTION_OPTION *Option;=0D + EFI_STRING TmpString;=0D + BOOLEAN Found;=0D +=0D + if (Statement =3D=3D NULL || IS_EMPTY_STRING (HiiString) || Value =3D=3D= NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *Value =3D 0;=0D +=0D + if (Statement->HiiStatement->Operand !=3D EFI_IFR_ORDERED_LIST_OP) {=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + if (IsListEmpty (&Statement->HiiStatement->OptionListHead)) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + Found =3D FALSE;=0D + Link =3D GetFirstNode (&Statement->HiiStatement->OptionListHead);=0D + while (!IsNull (&Statement->HiiStatement->OptionListHead, Link)) {=0D + Option =3D HII_QUESTION_OPTION_FROM_LINK (Link);=0D +=0D + TmpString =3D HiiGetRedfishString (Statement->ParentForm->ParentFormse= t->HiiHandle, Schema, Option->Text);=0D + if (TmpString !=3D NULL) {=0D + if (StrCmp (TmpString, HiiString) =3D=3D 0) {=0D + *Value =3D ExtendHiiValueToU64 (&Option->Value);=0D + Found =3D TRUE;=0D + }=0D + FreePool (TmpString);=0D + }=0D +=0D + if (Found) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + Link =3D GetNextNode (&Statement->HiiStatement->OptionListHead, Link);= =0D + }=0D +=0D + return EFI_NOT_FOUND;=0D +}=0D +=0D +/**=0D + Convert input ascii string to unicode string. It's caller's=0D + responsibility to free returned buffer using FreePool().=0D +=0D + @param[in] AsciiString Ascii string to be converted.=0D +=0D + @retval CHAR16 * Unicode string on return.=0D +=0D +**/=0D +EFI_STRING=0D +StrToUnicodeStr (=0D + IN CHAR8 *AsciiString=0D + )=0D +{=0D + UINTN StringLen;=0D + EFI_STRING Buffer;=0D + EFI_STATUS Status;=0D +=0D + if (AsciiString =3D=3D NULL || AsciiString[0] =3D=3D '\0') {=0D + return NULL;=0D + }=0D +=0D + StringLen =3D AsciiStrLen (AsciiString) + 1;=0D + Buffer =3D AllocatePool (StringLen * sizeof (CHAR16));=0D + if (Buffer =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + Status =3D AsciiStrToUnicodeStrS (AsciiString, Buffer, StringLen);=0D + if (EFI_ERROR (Status)) {=0D + FreePool (Buffer);=0D + return NULL;=0D + }=0D +=0D + return Buffer;=0D +}=0D +=0D +=0D +/**=0D + Return the full Redfish schema string from the given Schema and Version.= =0D +=0D + Returned schema string is: Schema + '.' + Version=0D +=0D + @param[in] Schema Schema string=0D + @param[in] Version Schema version string=0D +=0D + @retval CHAR8 * Schema string. NULL when errors occur.=0D +=0D +**/=0D +CHAR8 *=0D +GetFullSchemaString (=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version=0D + )=0D +{=0D + UINTN Size;=0D + CHAR8 *FullName;=0D +=0D + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version)) {=0D + return NULL;=0D + }=0D +=0D + Size =3D AsciiStrSize(CONFIGURE_LANGUAGE_PREFIX) + AsciiStrSize (Schema)= + AsciiStrSize (Version);=0D +=0D + FullName =3D AllocatePool (Size);=0D + if (FullName =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, out-of-resource\n", __FUNCTION__));=0D + return NULL;=0D + }=0D +=0D + AsciiSPrint (FullName, Size, "%a%a.%a", CONFIGURE_LANGUAGE_PREFIX, Schem= a, Version);=0D +=0D + return FullName;=0D +}=0D +=0D +/**=0D + Common implementation to get statement private instance.=0D +=0D + @param[in] RedfishPlatformConfigPrivate Private instance.=0D + @param[in] Schema Redfish schema string.=0D + @param[in] ConfigureLang Configure language that refe= rs to this statement.=0D + @param[out] Statement Statement instance=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +RedfishPlatformConfigGetStatementCommon (=0D + IN REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfig= Private,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING ConfigureLang,=0D + OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE **Statement=0D + )=0D +{=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement;=0D +=0D + if (RedfishPlatformConfigPrivate =3D=3D NULL || IS_EMPTY_STRING (Schema)= || IS_EMPTY_STRING (ConfigureLang) || Statement =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *Statement =3D NULL;=0D +=0D + Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status));=0D + return Status;=0D + }=0D +=0D + TargetStatement =3D GetStatementPrivateByConfigureLang (&RedfishPlatform= ConfigPrivate->FormsetList, Schema, ConfigureLang);=0D + if (TargetStatement =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, No match HII statement is found by the given= %s in schema %a\n", __FUNCTION__, ConfigureLang, Schema));=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + //=0D + // Find current HII question value.=0D + //=0D + Status =3D GetQuestionValue (=0D + TargetStatement->ParentForm->ParentFormset->HiiFormSet,=0D + TargetStatement->ParentForm->HiiForm,=0D + TargetStatement->HiiStatement,=0D + GetSetValueWithHiiDriver=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to get question current value: %r\n",= __FUNCTION__, Status));=0D + return Status;=0D + }=0D +=0D +=0D + if (TargetStatement->HiiStatement->Value.Type =3D=3D EFI_IFR_TYPE_UNDEFI= NED) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + //=0D + // Return Value.=0D + //=0D + *Statement =3D TargetStatement;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get Redfish value with the given Schema and Configure Language.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] Schema The Redfish schema to query.=0D + @param[in] Version The Redfish version to query.=0D + @param[in] ConfigureLang The target value which match this confi= gure Language.=0D + @param[out] Value The returned value.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigProtocolGetValue (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version,=0D + IN EFI_STRING ConfigureLang,=0D + OUT EDKII_REDFISH_VALUE *Value=0D + )=0D +{=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate;= =0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement;=0D + EFI_STRING_ID StringId;=0D + EFI_STRING_ID *StringIdArray;=0D + CHAR8 *FullSchema;=0D + EFI_STRING HiiString;=0D + UINTN Count;=0D + UINTN Index;=0D +=0D + if (This =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Ver= sion) || IS_EMPTY_STRING (ConfigureLang) || Value =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This);=0D + Value->Type =3D REDFISH_VALUE_TYPE_UNKNOWN;=0D + Value->ArrayCount =3D 0;=0D + Count =3D 0;=0D + FullSchema =3D NULL;=0D + HiiString =3D NULL;=0D + StringIdArray =3D NULL;=0D +=0D + FullSchema =3D GetFullSchemaString (Schema, Version);=0D + if (FullSchema =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + Status =3D RedfishPlatformConfigGetStatementCommon (RedfishPlatformConfi= gPrivate, FullSchema, ConfigureLang, &TargetStatement);=0D + if (EFI_ERROR (Status)) {=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + switch (TargetStatement->HiiStatement->Operand) {=0D + case EFI_IFR_ONE_OF_OP:=0D + StringId =3D HiiValueToOneOfOptionStringId (TargetStatement);=0D + if (StringId =3D=3D 0) {=0D + ASSERT (FALSE);=0D + Status =3D EFI_DEVICE_ERROR;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + Value->Value.Buffer =3D HiiGetRedfishAsciiString (TargetStatement->P= arentForm->ParentFormset->HiiHandle, FullSchema, StringId);=0D + if (Value->Value.Buffer =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + Value->Type =3D REDFISH_VALUE_TYPE_STRING;=0D + break;=0D + case EFI_IFR_STRING_OP:=0D + if (TargetStatement->HiiStatement->Value.Type !=3D EFI_IFR_TYPE_STRI= NG) {=0D + ASSERT (FALSE);=0D + Status =3D EFI_DEVICE_ERROR;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + Value->Type =3D REDFISH_VALUE_TYPE_STRING;=0D + Value->Value.Buffer =3D AllocateCopyPool (StrSize ((CHAR16 *)TargetS= tatement->HiiStatement->Value.Buffer), TargetStatement->HiiStatement->Value= .Buffer);=0D + if (Value->Value.Buffer =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto RELEASE_RESOURCE;=0D + }=0D + break;=0D + case EFI_IFR_CHECKBOX_OP:=0D + case EFI_IFR_NUMERIC_OP:=0D + Status =3D HiiValueToRedfishNumeric (&TargetStatement->HiiStatement-= >Value, Value);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to convert HII value to Redfish v= alue: %r\n", __FUNCTION__, Status));=0D + goto RELEASE_RESOURCE;=0D + }=0D + break;=0D + case EFI_IFR_ACTION_OP:=0D + if (TargetStatement->HiiStatement->Value.Type !=3D EFI_IFR_TYPE_ACTI= ON) {=0D + ASSERT (FALSE);=0D + Status =3D EFI_DEVICE_ERROR;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + //=0D + // Action has no value. Just return unknown type.=0D + //=0D + Value->Type =3D REDFISH_VALUE_TYPE_UNKNOWN;=0D + break;=0D + case EFI_IFR_ORDERED_LIST_OP:=0D + StringIdArray =3D HiiValueToOrderedListOptionStringId (TargetStateme= nt, &Count);=0D + if (StringIdArray =3D=3D NULL) {=0D + ASSERT (FALSE);=0D + Status =3D EFI_DEVICE_ERROR;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + Value->Value.StringArray =3D AllocatePool (sizeof (CHAR8 *) * Count)= ;=0D + if (Value->Value.StringArray =3D=3D NULL) {=0D + ASSERT (FALSE);=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + for (Index =3D 0; Index < Count; Index++) {=0D + ASSERT (StringIdArray[Index] !=3D 0);=0D + Value->Value.StringArray[Index] =3D HiiGetRedfishAsciiString (Targ= etStatement->ParentForm->ParentFormset->HiiHandle, FullSchema, StringIdArra= y[Index]);=0D + }=0D +=0D + Value->ArrayCount =3D Count;=0D + Value->Type =3D REDFISH_VALUE_TYPE_STRING_ARRAY;=0D + break;=0D + default:=0D + 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));=0D + ASSERT (FALSE);=0D + Status =3D EFI_UNSUPPORTED;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D +RELEASE_RESOURCE:=0D +=0D + if (FullSchema !=3D NULL) {=0D + FreePool (FullSchema);=0D + }=0D +=0D + if (HiiString !=3D NULL) {=0D + FreePool (HiiString);=0D + }=0D +=0D + if (StringIdArray !=3D NULL) {=0D + FreePool (StringIdArray);=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Function to save question value into HII database.=0D +=0D + @param[in] HiiFormset HII form-set instance=0D + @param[in] HiiForm HII form instance=0D + @param[in] HiiStatement HII statement that keeps new value.=0D + @param[in] Value New value to applyu.=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +RedfishPlatformConfigSaveQuestionValue (=0D + IN HII_FORMSET *HiiFormset,=0D + IN HII_FORM *HiiForm,=0D + IN HII_STATEMENT *HiiStatement,=0D + IN HII_STATEMENT_VALUE *Value=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + if (HiiFormset =3D=3D NULL || HiiForm =3D=3D NULL || HiiStatement =3D=3D= NULL || Value =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D SetQuestionValue (=0D + HiiFormset,=0D + HiiForm,=0D + HiiStatement,=0D + Value=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to set question value: %r\n", __FUNCT= ION__, Status));=0D + return Status;=0D + }=0D +=0D + Status =3D SubmitForm (HiiFormset, HiiForm);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to submit form: %r\n", __FUNCTION__, = Status));=0D + return Status;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Common implementation to set statement private instance.=0D +=0D + @param[in] RedfishPlatformConfigPrivate Private instance.=0D + @param[in] Schema Redfish schema string.=0D + @param[in] ConfigureLang Configure language that refe= rs to this statement.=0D + @param[in] Statement Statement instance=0D +=0D + @retval EFI_SUCCESS HII value is returned successfully.=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +RedfishPlatformConfigSetStatementCommon (=0D + IN REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING ConfigureLang,=0D + IN HII_STATEMENT_VALUE *StatementValue=0D + )=0D +{=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *TargetStatement;=0D + EFI_STRING TempBuffer;=0D + UINT8 *StringArray;=0D + UINTN Index;=0D + UINT64 Value;=0D + CHAR8 **CharArray;=0D +=0D + if (RedfishPlatformConfigPrivate =3D=3D NULL || IS_EMPTY_STRING (Schema)= || IS_EMPTY_STRING (ConfigureLang) || StatementValue =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + TempBuffer =3D NULL;=0D + StringArray =3D NULL;=0D +=0D + Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status));=0D + return Status;=0D + }=0D +=0D + TargetStatement =3D GetStatementPrivateByConfigureLang (&RedfishPlatform= ConfigPrivate->FormsetList, Schema, ConfigureLang);=0D + if (TargetStatement =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, No match HII statement is found by the given= %s in schema %a\n", __FUNCTION__, ConfigureLang, Schema));=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + if (StatementValue->Type !=3D TargetStatement->HiiStatement->Value.Type)= {=0D + //=0D + // We treat one-of type as string in Redfish. But one-of statement is = not=0D + // in string format from HII point of view. Do a patch here.=0D + //=0D + if (TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_ONE_OF_OP &&= StatementValue->Type =3D=3D EFI_IFR_TYPE_STRING) {=0D +=0D + TempBuffer =3D StrToUnicodeStr ((CHAR8 *)StatementValue->Buffer);=0D + if (TempBuffer =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + FreePool (StatementValue->Buffer);=0D + StatementValue->Buffer =3D NULL;=0D + StatementValue->BufferLen =3D 0;=0D +=0D + Status =3D HiiStringToOneOfOptionValue (TargetStatement, Schema, Tem= pBuffer, StatementValue);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to find option value by the given= %s\n", __FUNCTION__, TempBuffer));=0D + FreePool (TempBuffer);=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + FreePool (TempBuffer);=0D + } else if (TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_ORDER= ED_LIST_OP && StatementValue->Type =3D=3D EFI_IFR_TYPE_STRING) {=0D + //=0D + // We treat ordered list type as string in Redfish. But ordered list= statement is not=0D + // in string format from HII point of view. Do a patch here.=0D + //=0D + StringArray =3D AllocateZeroPool (TargetStatement->HiiStatement->Sto= rageWidth);=0D + if (StringArray =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + //=0D + // Arrage new option order from input string array=0D + //=0D + CharArray =3D (CHAR8 **)StatementValue->Buffer;=0D + for (Index =3D 0; Index < StatementValue->BufferLen; Index++) {=0D + TempBuffer =3D StrToUnicodeStr (CharArray[Index]);=0D + if (TempBuffer =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + Status =3D HiiStringToOrderedListOptionValue (TargetStatement, Sch= ema, TempBuffer, &Value);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (FALSE);=0D + continue;=0D + }=0D + FreePool (TempBuffer);=0D + OrderedListSetArrayData (StringArray, TargetStatement->HiiStatemen= t->Value.BufferValueType, Index, Value);=0D + }=0D +=0D + StatementValue->Type =3D EFI_IFR_TYPE_BUFFER;=0D + StatementValue->Buffer =3D StringArray;=0D + StatementValue->BufferLen =3D TargetStatement->HiiStatement->Storage= Width;=0D + StatementValue->BufferValueType =3D TargetStatement->HiiStatement->V= alue.BufferValueType;=0D + } else if (TargetStatement->HiiStatement->Operand =3D=3D EFI_IFR_NUMER= IC_OP && StatementValue->Type =3D=3D EFI_IFR_TYPE_NUM_SIZE_64) {=0D + //=0D + // Redfish only has numeric value type and it does not care about th= e value size.=0D + // Do a patch here so we have proper value size applied.=0D + //=0D + StatementValue->Type =3D TargetStatement->HiiStatement->Value.Type;= =0D + } else {=0D + DEBUG ((DEBUG_ERROR, "%a, catch value type mismatch! input type: 0x%= x but target value type: 0x%x\n", __FUNCTION__, StatementValue->Type, Targe= tStatement->HiiStatement->Value.Type));=0D + ASSERT (FALSE);=0D + }=0D + }=0D +=0D + Status =3D RedfishPlatformConfigSaveQuestionValue (=0D + TargetStatement->ParentForm->ParentFormset->HiiFormSet,=0D + TargetStatement->ParentForm->HiiForm,=0D + TargetStatement->HiiStatement,=0D + StatementValue=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to save question value: %r\n", __FUNC= TION__, Status));=0D + return Status;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Set Redfish value with the given Schema and Configure Language.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] Schema The Redfish schema to query.=0D + @param[in] Version The Redfish version to query.=0D + @param[in] ConfigureLang The target value which match this confi= gure Language.=0D + @param[in] Value The value to set.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigProtocolSetValue (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version,=0D + IN EFI_STRING ConfigureLang,=0D + IN EDKII_REDFISH_VALUE Value=0D + )=0D +{=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate;= =0D + CHAR8 *FullSchema;=0D + HII_STATEMENT_VALUE NewValue;=0D +=0D + if (This =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Ver= sion) || IS_EMPTY_STRING (ConfigureLang)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (Value.Type =3D=3D REDFISH_VALUE_TYPE_UNKNOWN || Value.Type >=3D REDF= ISH_VALUE_TYPE_MAX) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This);=0D + FullSchema =3D NULL;=0D +=0D + FullSchema =3D GetFullSchemaString (Schema, Version);=0D + if (FullSchema =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + ZeroMem (&NewValue, sizeof (HII_STATEMENT_VALUE));=0D +=0D + switch (Value.Type) {=0D + case REDFISH_VALUE_TYPE_INTEGER:=0D + case REDFISH_VALUE_TYPE_BOOLEAN:=0D + Status =3D RedfishNumericToHiiValue (&Value, &NewValue);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to convert Redfish value to Hii v= alue: %r\n", __FUNCTION__, Status));=0D + goto RELEASE_RESOURCE;=0D + }=0D + break;=0D + case REDFISH_VALUE_TYPE_STRING:=0D + NewValue.Type =3D EFI_IFR_TYPE_STRING;=0D + NewValue.BufferLen =3D (UINT16)AsciiStrSize (Value.Value.Buffer);=0D + NewValue.Buffer =3D AllocateCopyPool (NewValue.BufferLen, Value.Valu= e.Buffer);=0D + if (NewValue.Buffer =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto RELEASE_RESOURCE;=0D + }=0D + break;=0D + case REDFISH_VALUE_TYPE_STRING_ARRAY:=0D + NewValue.Type =3D EFI_IFR_TYPE_STRING;=0D + NewValue.BufferLen =3D (UINT16)Value.ArrayCount;=0D + NewValue.Buffer =3D (UINT8 *)Value.Value.StringArray;=0D + break;=0D + default:=0D + ASSERT (FALSE);=0D + break;=0D + }=0D +=0D + Status =3D RedfishPlatformConfigSetStatementCommon (RedfishPlatformConfi= gPrivate, FullSchema, ConfigureLang, &NewValue);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to set value to statement: %r\n", __F= UNCTION__, Status));=0D + }=0D +=0D +RELEASE_RESOURCE:=0D +=0D + if (FullSchema !=3D NULL) {=0D + FreePool (FullSchema);=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Get the list of Configure Language from platform configuration by the gi= ven Schema and Pattern.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] Schema The Redfish schema to query.=0D + @param[in] Version The Redfish version to query.=0D + @param[in] Pattern The target Configure Language pattern.= =0D + @param[out] ConfigureLangList The list of Configure Language.=0D + @param[out] Count The number of Configure Language in Con= figureLangList.=0D +=0D + @retval EFI_SUCCESS ConfigureLangList is returned successfu= lly.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigProtocolGetConfigureLang (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN CHAR8 *Schema,=0D + IN CHAR8 *Version,=0D + IN EFI_STRING Pattern,=0D + OUT EFI_STRING **ConfigureLangList,=0D + OUT UINTN *Count=0D + )=0D +{=0D + REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPr= ivate;=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST StatementList;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef;=0D + LIST_ENTRY *NextLink;=0D + EFI_STRING TmpString;=0D + EFI_STRING *TmpConfigureLangList;=0D + UINTN Index;=0D + CHAR8 *FullSchema;=0D +=0D + if (This =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Ver= sion) || Count =3D=3D NULL || ConfigureLangList =3D=3D NULL || IS_EMPTY_STR= ING (Pattern)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *Count =3D 0;=0D + *ConfigureLangList =3D NULL;=0D + FullSchema =3D NULL;=0D + RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This);=0D +=0D + Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status));=0D + return Status;=0D + }=0D +=0D + FullSchema =3D GetFullSchemaString (Schema, Version);=0D + if (FullSchema =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + Status =3D GetStatementPrivateByConfigureLangRegex (=0D + RedfishPlatformConfigPrivate->RegularExpressionProtocol,=0D + &RedfishPlatformConfigPrivate->FormsetList,=0D + FullSchema,=0D + Pattern,=0D + &StatementList=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, GetStatementPrivateByConfigureLangRegex fail= ure: %r\n", __FUNCTION__, Status));=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + if (!IsListEmpty (&StatementList.StatementList)) {=0D +=0D + TmpConfigureLangList =3D AllocateZeroPool (sizeof (CHAR16 *) * Stateme= ntList.Count);=0D + if (TmpConfigureLangList =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto RELEASE_RESOURCE;=0D + }=0D +=0D + Index =3D 0;=0D + NextLink =3D GetFirstNode (&StatementList.StatementList);=0D + while (!IsNull (&StatementList.StatementList, NextLink)) {=0D + StatementRef =3D REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK (Ne= xtLink);=0D + NextLink =3D GetNextNode (&StatementList.StatementList, NextLink);=0D +=0D + ASSERT (StatementRef->Statement->Description !=3D 0);=0D + if (StatementRef->Statement->Description !=3D 0) {=0D + TmpString =3D HiiGetRedfishString (StatementRef->Statement->Parent= Form->ParentFormset->HiiHandle, FullSchema, StatementRef->Statement->Descri= ption);=0D + ASSERT (TmpString !=3D NULL);=0D + if (TmpString !=3D NULL) {=0D + TmpConfigureLangList[Index] =3D AllocateCopyPool (StrSize (TmpSt= ring), TmpString);=0D + ASSERT (TmpConfigureLangList[Index] !=3D NULL);=0D + FreePool (TmpString);=0D + ++Index;=0D + }=0D + }=0D + }=0D + }=0D +=0D + *Count =3D StatementList.Count;=0D + *ConfigureLangList =3D TmpConfigureLangList;=0D +=0D +RELEASE_RESOURCE:=0D +=0D + if (FullSchema !=3D NULL) {=0D + FreePool (FullSchema);=0D + }=0D +=0D + ReleaseStatementList (&StatementList);=0D +=0D + return Status;=0D +}=0D +=0D +=0D +/**=0D + Get the list of supported Redfish schema from paltform configuration on = give HII handle.=0D +=0D + @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFI= G_PROTOCOL instance.=0D + @param[in] HiiHandle The target handle to search. If handle = is NULL,=0D + this function return all schema from HI= I database.=0D + @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'.=0D + The SupportedSchema is allocated by the= callee. It's caller's=0D + responsibility to free this buffer usin= g FreePool().=0D +=0D + @retval EFI_SUCCESS Schema is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigProtocolGetSupportedSchema (=0D + IN EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *This,=0D + IN EFI_HII_HANDLE HiiHandle, OPTIONA= L=0D + OUT CHAR8 **SupportedSchema=0D + )=0D +{=0D + REDFISH_PLATFORM_CONFIG_PRIVATE *RedfishPlatformConfigPrivate;= =0D + EFI_STATUS Status;=0D + LIST_ENTRY *HiiFormsetLink;=0D + LIST_ENTRY *HiiFormsetNextLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate;=0D + UINTN Index;=0D + UINTN StringSize;=0D + CHAR8 *StringBuffer;=0D + UINTN StringIndex;=0D +=0D + if (This =3D=3D NULL || SupportedSchema =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *SupportedSchema =3D NULL;=0D +=0D + RedfishPlatformConfigPrivate =3D REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_TH= IS (This);=0D +=0D + Status =3D ProcessPendingList (&RedfishPlatformConfigPrivate->FormsetLis= t, &RedfishPlatformConfigPrivate->PendingList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, ProcessPendingList failure: %r\n", __FUNCTIO= N__, Status));=0D + return Status;=0D + }=0D +=0D + if (IsListEmpty (&RedfishPlatformConfigPrivate->FormsetList)) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + //=0D + // Calculate for string buffer size.=0D + //=0D + StringSize =3D 0;=0D + HiiFormsetLink =3D GetFirstNode (&RedfishPlatformConfigPrivate->FormsetL= ist);=0D + while (!IsNull (&RedfishPlatformConfigPrivate->FormsetList, HiiFormsetLi= nk)) {=0D + HiiFormsetNextLink =3D GetNextNode (&RedfishPlatformConfigPrivate->For= msetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + if (HiiHandle !=3D NULL && HiiHandle !=3D HiiFormsetPrivate->HiiHandle= ) {=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + continue;=0D + }=0D +=0D + if (HiiFormsetPrivate->SupportedSchema.Count > 0) {=0D + for (Index =3D 0; Index < HiiFormsetPrivate->SupportedSchema.Count; = Index++) {=0D + StringSize +=3D AsciiStrSize (HiiFormsetPrivate->SupportedSchema.S= chemaList[Index]);=0D + }=0D + }=0D +=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + if (StringSize =3D=3D 0) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + StringBuffer =3D AllocatePool (StringSize);=0D + if (StringBuffer =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + StringIndex =3D 0;=0D + HiiFormsetLink =3D GetFirstNode (&RedfishPlatformConfigPrivate->FormsetL= ist);=0D + while (!IsNull (&RedfishPlatformConfigPrivate->FormsetList, HiiFormsetLi= nk)) {=0D + HiiFormsetNextLink =3D GetNextNode (&RedfishPlatformConfigPrivate->For= msetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + if (HiiHandle !=3D NULL && HiiHandle !=3D HiiFormsetPrivate->HiiHandle= ) {=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + continue;=0D + }=0D +=0D + if (HiiFormsetPrivate->SupportedSchema.Count > 0) {=0D + for (Index =3D 0; Index < HiiFormsetPrivate->SupportedSchema.Count; = Index++) {=0D + AsciiStrCpyS (&StringBuffer[StringIndex], (StringSize - StringInde= x), HiiFormsetPrivate->SupportedSchema.SchemaList[Index]);=0D + StringIndex +=3D AsciiStrLen (HiiFormsetPrivate->SupportedSchema.S= chemaList[Index]);=0D + StringBuffer[StringIndex] =3D ';';=0D + ++StringIndex;=0D + }=0D + }=0D +=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + StringBuffer[--StringIndex] =3D '\0';=0D +=0D + *SupportedSchema =3D StringBuffer;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Functions which are registered to receive notification of=0D + database events have this prototype. The actual event is encoded=0D + in NotifyType. The following table describes how PackageType,=0D + PackageGuid, Handle, and Package are used for each of the=0D + notification types.=0D +=0D + @param[in] PackageType Package type of the notification.=0D + @param[in] PackageGuid If PackageType is=0D + EFI_HII_PACKAGE_TYPE_GUID, then this is=0D + the pointer to the GUID from the Guid=0D + field of EFI_HII_PACKAGE_GUID_HEADER.=0D + Otherwise, it must be NULL.=0D + @param[in] Package Points to the package referred to by the=0D + notification Handle The handle of the package=0D + list which contains the specified package.=0D + @param[in] Handle The HII handle.=0D + @param[in] NotifyType The type of change concerning the=0D + database. See=0D + EFI_HII_DATABASE_NOTIFY_TYPE.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigFormUpdateNotify (=0D + IN UINT8 PackageType,=0D + IN CONST EFI_GUID *PackageGuid,=0D + IN CONST EFI_HII_PACKAGE_HEADER *Package,=0D + IN EFI_HII_HANDLE Handle,=0D + IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + if (NotifyType =3D=3D EFI_HII_DATABASE_NOTIFY_NEW_PACK || NotifyType =3D= =3D EFI_HII_DATABASE_NOTIFY_ADD_PACK) {=0D + //=0D + // HII formset on this handle is updated by driver during run-time. Th= e formset needs to be reloaded.=0D + //=0D + Status =3D NotifyFormsetUpdate (Handle, &mRedfishPlatformConfigPrivate= ->PendingList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to notify updated formset of HII ha= ndle: 0x%x\n", __FUNCTION__, Handle));=0D + return Status;=0D + }=0D + } else if (NotifyType =3D=3D EFI_HII_DATABASE_NOTIFY_REMOVE_PACK) {=0D + //=0D + // HII resource is removed. The formset is no longer exist.=0D + //=0D + Status =3D NotifyFormsetDeleted (Handle, &mRedfishPlatformConfigPrivat= e->PendingList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to notify deleted formset of HII ha= ndle: 0x%x\n", __FUNCTION__, Handle));=0D + return Status;=0D + }=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + This is a EFI_HII_STRING_PROTOCOL notification event handler.=0D +=0D + Install HII package notification.=0D +=0D + @param[in] Event Event whose notification function is being invoked.= =0D + @param[in] Context Pointer to the notification function's context.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +HiiStringProtocolInstalled (=0D + IN EFI_EVENT Event,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + //=0D + // Locate HII database protocol.=0D + //=0D + Status =3D gBS->LocateProtocol (=0D + &gEfiHiiStringProtocolGuid,=0D + NULL,=0D + (VOID **)&mRedfishPlatformConfigPrivate->HiiString=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, locate EFI_HII_STRING_PROTOCOL failure: %r\n= ", __FUNCTION__, Status));=0D + return;=0D + }=0D +=0D + gBS->CloseEvent (Event);=0D + mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent =3D NULL;=0D +}=0D +=0D +/**=0D + This is a EFI_HII_DATABASE_PROTOCOL notification event handler.=0D +=0D + Install HII package notification.=0D +=0D + @param[in] Event Event whose notification function is being invoked.= =0D + @param[in] Context Pointer to the notification function's context.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +HiiDatabaseProtocolInstalled (=0D + IN EFI_EVENT Event,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + //=0D + // Locate HII database protocol.=0D + //=0D + Status =3D gBS->LocateProtocol (=0D + &gEfiHiiDatabaseProtocolGuid,=0D + NULL,=0D + (VOID **)&mRedfishPlatformConfigPrivate->HiiDatabase=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, locate EFI_HII_DATABASE_PROTOCOL failure: %r= \n", __FUNCTION__, Status));=0D + return;=0D + }=0D +=0D + //=0D + // Register package notification when new form package is installed.=0D + //=0D + Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->RegisterPackageNo= tify (=0D + mRedfishPlatformConfigPrivate= ->HiiDatabase,=0D + EFI_HII_PACKAGE_FORMS,=0D + NULL,=0D + RedfishPlatformConfigFormUpda= teNotify,=0D + EFI_HII_DATABASE_NOTIFY_NEW_P= ACK,=0D + &mRedfishPlatformConfigPrivat= e->NotifyHandle=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, RegisterPackageNotify for EFI_HII_DATABASE_N= OTIFY_NEW_PACK failure: %r\n", __FUNCTION__, Status));=0D + }=0D +=0D + //=0D + // Register package notification when new form package is updated.=0D + //=0D + Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->RegisterPackageNo= tify (=0D + mRedfishPlatformConfigPrivate= ->HiiDatabase,=0D + EFI_HII_PACKAGE_FORMS,=0D + NULL,=0D + RedfishPlatformConfigFormUpda= teNotify,=0D + EFI_HII_DATABASE_NOTIFY_ADD_P= ACK,=0D + &mRedfishPlatformConfigPrivat= e->NotifyHandle=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, RegisterPackageNotify for EFI_HII_DATABASE_N= OTIFY_NEW_PACK failure: %r\n", __FUNCTION__, Status));=0D + }=0D +=0D +#if REDFISH_PLATFORM_CONFIG_DELETE_EXPIRED_FORMSET=0D + //=0D + // Register package notification when new form package is removed.=0D + //=0D + Status =3D mRedfishPlatformConfigPrivate->HiiDatabase->RegisterPackageNo= tify (=0D + mRedfishPlatformConfigPrivate= ->HiiDatabase,=0D + EFI_HII_PACKAGE_FORMS,=0D + NULL,=0D + RedfishPlatformConfigFormUpda= teNotify,=0D + EFI_HII_DATABASE_NOTIFY_REMOV= E_PACK,=0D + &mRedfishPlatformConfigPrivat= e->NotifyHandle=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, RegisterPackageNotify for EFI_HII_DATABASE_N= OTIFY_NEW_PACK failure: %r\n", __FUNCTION__, Status));=0D + }=0D +#endif=0D +=0D + gBS->CloseEvent (Event);=0D + mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent =3D NULL;=0D +=0D +}=0D +=0D +/**=0D + This is a EFI_REGULAR_EXPRESSION_PROTOCOL notification event handler.=0D +=0D + @param[in] Event Event whose notification function is being invoked.= =0D + @param[in] Context Pointer to the notification function's context.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +RegexProtocolInstalled (=0D + IN EFI_EVENT Event,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + //=0D + // Locate regular expression protocol.=0D + //=0D + Status =3D gBS->LocateProtocol (=0D + &gEfiRegularExpressionProtocolGuid,=0D + NULL,=0D + (VOID **)&mRedfishPlatformConfigPrivate->RegularExpressi= onProtocol=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, locate EFI_REGULAR_EXPRESSION_PROTOCOL failu= re: %r\n", __FUNCTION__, Status));=0D + return;=0D + }=0D +=0D + gBS->CloseEvent (Event);=0D + mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent =3D NULL;=0D +=0D +}=0D +=0D +/**=0D + Unloads an image.=0D +=0D + @param ImageHandle Handle that identifies the image to be unl= oaded.=0D +=0D + @retval EFI_SUCCESS The image has been unloaded.=0D + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigDxeUnload (=0D + IN EFI_HANDLE ImageHandle=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + if (mRedfishPlatformConfigPrivate !=3D NULL) {=0D + Status =3D gBS->UninstallProtocolInterface (=0D + mRedfishPlatformConfigPrivate->ImageHandle,=0D + &gEdkIIRedfishPlatformConfigProtocolGuid,=0D + (VOID*)&mRedfishPlatformConfigPrivate->Protocol=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, can not uninstall gEdkIIRedfishPlatformCon= figProtocolGuid: %r\n", __FUNCTION__, Status));=0D + ASSERT (FALSE);=0D + }=0D +=0D + //=0D + // Close events=0D + //=0D + if (mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent !=3D NULL= ) {=0D + gBS->CloseEvent (mRedfishPlatformConfigPrivate->HiiDbNotify.Protocol= Event);=0D + }=0D + if (mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent !=3D = NULL) {=0D + gBS->CloseEvent (mRedfishPlatformConfigPrivate->HiiStringNotify.Prot= ocolEvent);=0D + }=0D + if (mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent !=3D NULL= ) {=0D + gBS->CloseEvent (mRedfishPlatformConfigPrivate->RegexNotify.Protocol= Event);=0D + }=0D +=0D + //=0D + // Unregister package notification.=0D + //=0D + if (mRedfishPlatformConfigPrivate->NotifyHandle !=3D NULL) {=0D + mRedfishPlatformConfigPrivate->HiiDatabase->UnregisterPackageNotify = (=0D + mRedfishPlatformConfigPrivate->H= iiDatabase,=0D + mRedfishPlatformConfigPrivate->N= otifyHandle=0D + );=0D + }=0D +=0D + ReleaseFormsetList (&mRedfishPlatformConfigPrivate->FormsetList);=0D + FreePool (mRedfishPlatformConfigPrivate);=0D + mRedfishPlatformConfigPrivate =3D NULL;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +=0D +/**=0D + This is the declaration of an EFI image entry point. This entry point is= =0D + the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers includ= ing=0D + both device drivers and bus drivers.=0D +=0D + @param ImageHandle The firmware allocated handle for the UEFI= image.=0D + @param SystemTable A pointer to the EFI System Table.=0D +=0D + @retval EFI_SUCCESS The operation completed successfully.=0D + @retval Others An unexpected error occurred.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishPlatformConfigDxeEntryPoint (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + mRedfishPlatformConfigPrivate =3D (REDFISH_PLATFORM_CONFIG_PRIVATE *)All= ocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_PRIVATE));=0D + if (mRedfishPlatformConfigPrivate =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, can not allocate pool for REDFISH_PLATFORM_C= ONFIG_PRIVATE\n", __FUNCTION__));=0D + ASSERT (FALSE);=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + //=0D + // Protocol initialization=0D + //=0D + mRedfishPlatformConfigPrivate->ImageHandle =3D ImageHandle;=0D + mRedfishPlatformConfigPrivate->Protocol.GetValue =3D RedfishPlatformConf= igProtocolGetValue;=0D + mRedfishPlatformConfigPrivate->Protocol.SetValue =3D RedfishPlatformConf= igProtocolSetValue;=0D + mRedfishPlatformConfigPrivate->Protocol.GetConfigureLang =3D RedfishPlat= formConfigProtocolGetConfigureLang;=0D + mRedfishPlatformConfigPrivate->Protocol.GetSupportedSchema =3D RedfishPl= atformConfigProtocolGetSupportedSchema;=0D +=0D + InitializeListHead (&mRedfishPlatformConfigPrivate->FormsetList);=0D + InitializeListHead (&mRedfishPlatformConfigPrivate->PendingList);=0D +=0D + Status =3D gBS->InstallProtocolInterface (=0D + &ImageHandle,=0D + &gEdkIIRedfishPlatformConfigProtocolGuid,=0D + EFI_NATIVE_INTERFACE,=0D + (VOID*)&mRedfishPlatformConfigPrivate->Protocol=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, can not install gEdkIIRedfishPlatformConfigP= rotocolGuid: %r\n", __FUNCTION__, Status));=0D + ASSERT (FALSE);=0D + }=0D +=0D + //=0D + // Install protocol notification if HII database protocol is installed.= =0D + //=0D + mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent =3D EfiCreatePr= otocolNotifyEvent (=0D + &gEfiHiiData= baseProtocolGuid,=0D + TPL_CALLBACK= ,=0D + HiiDatabaseP= rotocolInstalled,=0D + NULL,=0D + &mRedfishPla= tformConfigPrivate->HiiDbNotify.Registration=0D + );=0D + if (mRedfishPlatformConfigPrivate->HiiDbNotify.ProtocolEvent =3D=3D NULL= ) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to create protocol notification for g= EfiHiiDatabaseProtocolGuid\n", __FUNCTION__));=0D + ASSERT (FALSE);=0D + }=0D +=0D + //=0D + // Install protocol notification if HII string protocol is installed.=0D + //=0D + mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent =3D EfiCrea= teProtocolNotifyEvent (=0D + &gEfiHii= StringProtocolGuid,=0D + TPL_CALL= BACK,=0D + HiiStrin= gProtocolInstalled,=0D + NULL,=0D + &mRedfis= hPlatformConfigPrivate->HiiStringNotify.Registration=0D + );=0D + if (mRedfishPlatformConfigPrivate->HiiStringNotify.ProtocolEvent =3D=3D = NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to create protocol notification for g= EfiHiiStringProtocolGuid\n", __FUNCTION__));=0D + ASSERT (FALSE);=0D + }=0D +=0D + //=0D + // Install protocol notification if regular expression protocol is insta= lled.=0D + //=0D + mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent =3D EfiCreatePr= otocolNotifyEvent (=0D + &gEfiRegular= ExpressionProtocolGuid,=0D + TPL_CALLBACK= ,=0D + RegexProtoco= lInstalled,=0D + NULL,=0D + &mRedfishPla= tformConfigPrivate->RegexNotify.Registration=0D + );=0D + if (mRedfishPlatformConfigPrivate->RegexNotify.ProtocolEvent =3D=3D NULL= ) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to create protocol notification for g= EfiRegularExpressionProtocolGuid\n", __FUNCTION__));=0D + ASSERT (FALSE);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h index 99a613d229..d3f7af55ad 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h @@ -1,64 +1,64 @@ -/** @file - This file defines the EDKII Redfish Platform Config Protocol interface. - - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef EDKII_REDFISH_PLATFORM_CONFIG_DXE_H_ -#define EDKII_REDFISH_PLATFORM_CONFIG_DXE_H_ - -#include - -// -// Libraries -// -#include -#include -#include -#include -#include -#include -#include -#include - -// -// Produced Protocols -// -#include -#include -#include -#include - -// -// Definition of EDKII_REDFISH_PLATFORM_CONFIG_NOTIFY. -// -typedef struct { - EFI_EVENT ProtocolEvent; // Protocol notification ev= ent. - VOID *Registration; // Protocol notification re= gistration. -} REDFISH_PLATFORM_CONFIG_NOTIFY; - -// -// Definition of REDFISH_PLATFORM_CONFIG_PRIVATE. -// -typedef struct { - EFI_HANDLE ImageHandle; //= Driver image handle. - EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL Protocol; - REDFISH_PLATFORM_CONFIG_NOTIFY HiiDbNotify; - EFI_HII_DATABASE_PROTOCOL *HiiDatabase; //= The HII database protocol. - REDFISH_PLATFORM_CONFIG_NOTIFY HiiStringNotify; - EFI_HII_STRING_PROTOCOL *HiiString; //= HII String Protocol. - REDFISH_PLATFORM_CONFIG_NOTIFY RegexNotify; - EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionProtocol; //= Regular Expression Protocol. - EFI_HANDLE NotifyHandle; //= The notify handle. - LIST_ENTRY FormsetList; //= The list to keep cached HII formset. - LIST_ENTRY PendingList; //= The list to keep updated HII handle. -} REDFISH_PLATFORM_CONFIG_PRIVATE; - -#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-" - -#endif +/** @file=0D + This file defines the EDKII Redfish Platform Config Protocol interface.= =0D +=0D + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef EDKII_REDFISH_PLATFORM_CONFIG_DXE_H_=0D +#define EDKII_REDFISH_PLATFORM_CONFIG_DXE_H_=0D +=0D +#include =0D +=0D +//=0D +// Libraries=0D +//=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +//=0D +// Produced Protocols=0D +//=0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +//=0D +// Definition of EDKII_REDFISH_PLATFORM_CONFIG_NOTIFY.=0D +//=0D +typedef struct {=0D + EFI_EVENT ProtocolEvent; // Protocol notification ev= ent.=0D + VOID *Registration; // Protocol notification re= gistration.=0D +} REDFISH_PLATFORM_CONFIG_NOTIFY;=0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_PRIVATE.=0D +//=0D +typedef struct {=0D + EFI_HANDLE ImageHandle; //= Driver image handle.=0D + EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL Protocol;=0D + REDFISH_PLATFORM_CONFIG_NOTIFY HiiDbNotify;=0D + EFI_HII_DATABASE_PROTOCOL *HiiDatabase; //= The HII database protocol.=0D + REDFISH_PLATFORM_CONFIG_NOTIFY HiiStringNotify;=0D + EFI_HII_STRING_PROTOCOL *HiiString; //= HII String Protocol.=0D + REDFISH_PLATFORM_CONFIG_NOTIFY RegexNotify;=0D + EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionProtocol; //= Regular Expression Protocol.=0D + EFI_HANDLE NotifyHandle; //= The notify handle.=0D + LIST_ENTRY FormsetList; //= The list to keep cached HII formset.=0D + LIST_ENTRY PendingList; //= The list to keep updated HII handle.=0D +} REDFISH_PLATFORM_CONFIG_PRIVATE;=0D +=0D +#define REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS(a) BASE_CR (a, REDFISH_= PLATFORM_CONFIG_PRIVATE, Protocol)=0D +#define REGULAR_EXPRESSION_INCLUDE_ALL L".*"=0D +#define CONFIGURE_LANGUAGE_PREFIX "x-uefi-redfish-"=0D +=0D +#endif=0D diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.i= nf b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf index 16739bef7a..81b22e03c3 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf @@ -1,53 +1,53 @@ -## @file -# Implementation of EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL interfaces. -# -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D RedfishPlatformConfigDxe - FILE_GUID =3D BEAEFFE1-0633-41B5-913C-9389339C2927 - MODULE_TYPE =3D DXE_DRIVER - VERSION_STRING =3D 1.0 - ENTRY_POINT =3D RedfishPlatformConfigDxeEntryPoint - UNLOAD_IMAGE =3D RedfishPlatformConfigDxeUnload - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - RedfishPkg/RedfishPkg.dec - -[Sources] - RedfishPlatformConfigDxe.h - RedfishPlatformConfigDxe.c - RedfishPlatformConfigImpl.h - RedfishPlatformConfigImpl.c - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - DevicePathLib - HiiLib - HiiUtilityLib - MemoryAllocationLib - PrintLib - UefiLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - UefiDriverEntryPoint - -[Protocols] - gEdkIIRedfishPlatformConfigProtocolGuid ## PRODUCED - gEfiHiiDatabaseProtocolGuid ## CONSUMED - gEfiHiiStringProtocolGuid ## CONSUMED - gEfiRegularExpressionProtocolGuid ## CONSUMED - -[Guids] - gEfiRegexSyntaxTypePerlGuid ## CONSUMED - -[Depex] +## @file=0D +# Implementation of EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL interfaces.=0D +#=0D +# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D RedfishPlatformConfigDxe=0D + FILE_GUID =3D BEAEFFE1-0633-41B5-913C-9389339C2927=0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D RedfishPlatformConfigDxeEntryPoint=0D + UNLOAD_IMAGE =3D RedfishPlatformConfigDxeUnload=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + RedfishPkg/RedfishPkg.dec=0D +=0D +[Sources]=0D + RedfishPlatformConfigDxe.h=0D + RedfishPlatformConfigDxe.c=0D + RedfishPlatformConfigImpl.h=0D + RedfishPlatformConfigImpl.c=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + BaseMemoryLib=0D + DebugLib=0D + DevicePathLib=0D + HiiLib=0D + HiiUtilityLib=0D + MemoryAllocationLib=0D + PrintLib=0D + UefiLib=0D + UefiBootServicesTableLib=0D + UefiRuntimeServicesTableLib=0D + UefiDriverEntryPoint=0D +=0D +[Protocols]=0D + gEdkIIRedfishPlatformConfigProtocolGuid ## PRODUCED=0D + gEfiHiiDatabaseProtocolGuid ## CONSUMED=0D + gEfiHiiStringProtocolGuid ## CONSUMED=0D + gEfiRegularExpressionProtocolGuid ## CONSUMED=0D +=0D +[Guids]=0D + gEfiRegexSyntaxTypePerlGuid ## CONSUMED=0D +=0D +[Depex]=0D TRUE \ No newline at end of file diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.= c b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c index d9eab6c883..369ebb220c 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c @@ -1,1240 +1,1286 @@ -/** @file - - The implementation of EDKII Redfidh Platform Config Protocol. - - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ -#include "RedfishPlatformConfigDxe.h" -#include "RedfishPlatformConfigImpl.h" - -extern REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate; - -/** - Debug dump HII string - - @param[in] HiiHandle HII handle instance - @param[in] StringId HII string to dump - - @retval EFI_SUCCESS Dump HII string successfully - @retval Others Errors occur - -**/ -EFI_STATUS -DumpHiiString ( - IN EFI_HII_HANDLE HiiHandle, - IN EFI_STRING_ID StringId - ) -{ - EFI_STRING String; - - if (HiiHandle =3D=3D NULL || StringId =3D=3D 0) { - DEBUG ((DEBUG_INFO, "???")); - return EFI_INVALID_PARAMETER; - } - - String =3D HiiGetString (HiiHandle, StringId, NULL); - if (String =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - DEBUG ((DEBUG_INFO, "%s", String)); - FreePool (String); - - return EFI_SUCCESS; -} - -/** - Debug dump HII form-set data - - @param[in] FormsetPrivate HII form-set private instance. - - @retval EFI_SUCCESS Dump form-set successfully - @retval Others Errors occur - -**/ -EFI_STATUS -DumpFormset ( - IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate - ) -{ - LIST_ENTRY *HiiFormLink; - LIST_ENTRY *HiiNextFormLink; - REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate; - LIST_ENTRY *HiiStatementLink; - LIST_ENTRY *HiiNextStatementLink; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; - UINTN Index; - - if (FormsetPrivate =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - Index =3D 0; - HiiFormLink =3D GetFirstNode (&FormsetPrivate->HiiFormList); - while (!IsNull (&FormsetPrivate->HiiFormList, HiiFormLink)) { - HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink= ); - HiiNextFormLink =3D GetNextNode (&FormsetPrivate->HiiFormList, HiiForm= Link); - - DEBUG ((DEBUG_INFO, " [%d] form: %d title: ", ++Index, HiiFormPrivate= ->Id)); - DumpHiiString (FormsetPrivate->HiiHandle, HiiFormPrivate->Title); - DEBUG ((DEBUG_INFO, "\n")); - - HiiStatementLink =3D GetFirstNode (&HiiFormPrivate->StatementList); - while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) { - HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK = (HiiStatementLink); - HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementList= , HiiStatementLink); - - DEBUG ((DEBUG_INFO, " QID: 0x%x Prompt: ", HiiStatementPrivate->Q= uestionId)); - DumpHiiString (FormsetPrivate->HiiHandle, HiiStatementPrivate->Descr= iption); - DEBUG ((DEBUG_INFO, "\n")); - - HiiStatementLink =3D HiiNextStatementLink; - } - - HiiFormLink =3D HiiNextFormLink; - } - - return EFI_SUCCESS; -} - -/** - Debug dump HII form-set list - - @param[in] FormsetList Form-set list instance - - @retval EFI_SUCCESS Dump list successfully - @retval Others Errors occur - -**/ -EFI_STATUS -DumpFormsetList ( - IN LIST_ENTRY *FormsetList - ) -{ - LIST_ENTRY *HiiFormsetLink; - LIST_ENTRY *HiiFormsetNextLink; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate; - UINTN Index; - - if (FormsetList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (IsListEmpty (FormsetList)) { - DEBUG ((DEBUG_INFO, "%a, Empty formset list\n", __FUNCTION__)); - return EFI_SUCCESS; - } - - Index =3D 0; - HiiFormsetLink =3D GetFirstNode (FormsetList); - while (!IsNull (FormsetList, HiiFormsetLink)) { - HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - DEBUG ((DEBUG_INFO, "[%d] HII Handle: 0x%x formset: %g at %s\n", ++Ind= ex, HiiFormsetPrivate->HiiHandle, &HiiFormsetPrivate->Guid, HiiFormsetPriva= te->DevicePathStr)); - DumpFormset (HiiFormsetPrivate); - - HiiFormsetLink =3D HiiFormsetNextLink; - } - - return EFI_SUCCESS; -} - -/** - Retrieves a string from a string package in a English language. The - returned string is allocated using AllocatePool(). The caller is respon= sible - for freeing the allocated buffer using FreePool(). - - If HiiHandle is NULL, then ASSERT(). - If StringId is 0, then ASSET. - - @param[in] HiiStringProtocol EFI_HII_STRING_PROTOCOL instance. - @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. - -**/ -EFI_STRING -HiiGetRedfishString ( - IN EFI_HII_HANDLE HiiHandle, - IN CHAR8 *Language, - IN EFI_STRING_ID StringId - ) -{ - EFI_STATUS Status; - UINTN StringSize; - CHAR16 TempString; - EFI_STRING String; - - if (mRedfishPlatformConfigPrivate->HiiString =3D=3D NULL || HiiHandle = =3D=3D NULL || StringId =3D=3D 0 || IS_EMPTY_STRING (Language)) { - ASSERT (FALSE); - return NULL; - } - - // - // Retrieve the size of the string in the string package for the BestLan= guage - // - StringSize =3D 0; - Status =3D mRedfishPlatformConfigPrivate->HiiString->GetString ( - mRedfishPlatformConfigPrivate= ->HiiString, - Language, - HiiHandle, - StringId, - &TempString, - &StringSize, - NULL - ); - // - // If GetString() returns EFI_SUCCESS for a zero size, - // then there are no supported languages registered for HiiHandle. If G= etString() - // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is n= ot present - // in the HII Database - // - if (Status !=3D EFI_BUFFER_TOO_SMALL) { - return NULL; - } - - // - // Allocate a buffer for the return string - // - String =3D AllocateZeroPool (StringSize); - if (String =3D=3D NULL) { - return NULL; - } - - // - // Retrieve the string from the string package - // - Status =3D mRedfishPlatformConfigPrivate->HiiString->GetString ( - mRedfishPlatformConfigPrivate= ->HiiString, - Language, - HiiHandle, - StringId, - String, - &StringSize, - NULL - ); - if (EFI_ERROR (Status)) { - // - // Free the buffer and return NULL if the supported languages can not = be retrieved. - // - FreePool (String); - String =3D NULL; - } - - // - // Return the Null-terminated Unicode string - // - return String; -} - -/** - Get 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. - -**/ -EFI_STRING -HiiGetEnglishString ( - IN EFI_HII_HANDLE HiiHandle, - IN EFI_STRING_ID StringId - ) -{ - return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId); -} - -/** - Check and see if this is supported schema or not. - - @param[in] SupportedSchema The list of supported schema. - @param[in] Schema Schema string to be checked. - - @retval BOOLEAN TRUE if this is supported schema. FALSE ot= herwise. - -**/ -BOOLEAN -CheckSupportedSchema ( - IN REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema, - IN CHAR8 *Schema - ) -{ - UINTN Index; - - if (SupportedSchema =3D=3D NULL || IS_EMPTY_STRING (Schema)) { - return FALSE; - } - - if (SupportedSchema->Count =3D=3D 0) { - return FALSE; - } - - for (Index =3D 0; Index < SupportedSchema->Count; Index++) { - if (AsciiStrCmp (SupportedSchema->SchemaList[Index], Schema) =3D=3D 0)= { - return TRUE; - } - } - - return FALSE; -} - -/** - Get the list of supported schema from the given HII handle. - - @param[in] HiiHandle HII handle instance. - @param[out] SupportedSchema Supported schema on this HII handle. - - @retval EFI_SUCCESS Schema list is returned. - @retval EFI_INVALID_PARAMETER HiiHandle is NULL or SupportedSchema is NU= LL. - @retval EFI_NOT_FOUND No supported schema found. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -GetSupportedSchema ( - IN EFI_HII_HANDLE HiiHandle, - OUT REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema - ) -{ - CHAR8 *SupportedLanguages; - UINTN Index; - UINTN LangIndex; - UINTN Count; - UINTN StrSize; - UINTN ListIndex; - - if (HiiHandle =3D=3D NULL || SupportedSchema =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - SupportedSchema->Count =3D 0; - - SupportedLanguages =3D HiiGetSupportedLanguages (HiiHandle); - if (SupportedLanguages =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - Index =3D 0; - LangIndex =3D 0; - Count =3D 0; - while (TRUE) { - if (SupportedLanguages[Index] =3D=3D ';' || SupportedLanguages[Index] = =3D=3D '\0') { - if (AsciiStrnCmp (&SupportedLanguages[LangIndex], X_UEFI_SCHEMA_PREF= IX, AsciiStrLen (X_UEFI_SCHEMA_PREFIX)) =3D=3D 0) { - ++Count; - } - LangIndex =3D Index + 1; - } - - if (SupportedLanguages[Index] =3D=3D '\0') { - break; - } - - ++Index; - } - - if (Count =3D=3D 0) { - return EFI_NOT_FOUND; - } - - SupportedSchema->Count =3D Count; - SupportedSchema->SchemaList =3D AllocatePool (sizeof (CHAR8 *) * Count); - if (SupportedSchema->SchemaList =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Index =3D 0; - LangIndex =3D 0; - ListIndex =3D 0; - while (TRUE) { - - if (SupportedLanguages[Index] =3D=3D ';' || SupportedLanguages[Index] = =3D=3D '\0') { - if (AsciiStrnCmp (&SupportedLanguages[LangIndex], X_UEFI_SCHEMA_PREF= IX, AsciiStrLen (X_UEFI_SCHEMA_PREFIX)) =3D=3D 0) { - StrSize =3D Index - LangIndex; - SupportedSchema->SchemaList[ListIndex] =3D AllocateCopyPool ((StrS= ize + 1), &SupportedLanguages[LangIndex]); - SupportedSchema->SchemaList[ListIndex][StrSize] =3D '\0'; - ++ListIndex; - } - - LangIndex =3D Index + 1; - } - - if (SupportedLanguages[Index] =3D=3D '\0') { - break; - } - - ++Index; - } - - return EFI_SUCCESS; -} - -/** - Search and find statement private instance by given regular expression p= atthern - which describes the Configure Language. - - @param[in] RegularExpressionProtocol Regular express protocol. - @param[in] FormsetList Form-set list to search. - @param[in] Schema Schema to be matched. - @param[in] Pattern Regular expression pattern. - @param[out] StatementList Statement list that match above = pattern. - - @retval EFI_SUCCESS Statement list is returned. - @retval EFI_INVALID_PARAMETER Input parameter is NULL. - @retval EFI_NOT_READY Regular express protocol is NULL. - @retval EFI_NOT_FOUND No statement is found. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -GetStatementPrivateByConfigureLangRegex ( - IN EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionPr= otocol, - IN LIST_ENTRY *FormsetList, - IN CHAR8 *Schema, - IN EFI_STRING Pattern, - OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList - ) -{ - LIST_ENTRY *HiiFormsetLink; - LIST_ENTRY *HiiFormsetNextLink; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate; - LIST_ENTRY *HiiFormLink; - LIST_ENTRY *HiiNextFormLink; - REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate; - LIST_ENTRY *HiiStatementLink; - LIST_ENTRY *HiiNextStatementLink; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; - EFI_STRING TmpString; - UINTN CaptureCount; - BOOLEAN IsMatch; - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef; - - if (FormsetList =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRI= NG (Pattern) || StatementList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (RegularExpressionProtocol =3D=3D NULL) { - return EFI_NOT_READY; - } - - StatementList->Count =3D 0; - InitializeListHead (&StatementList->StatementList); - - if (IsListEmpty (FormsetList)) { - return EFI_NOT_FOUND; - } - - HiiFormsetLink =3D GetFirstNode (FormsetList); - while (!IsNull (FormsetList, HiiFormsetLink)) { - HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - // - // Performance check. - // If there is no desired Redfish schema found, skip this formset. - // - if (!CheckSupportedSchema (&HiiFormsetPrivate->SupportedSchema, Schema= )) { - HiiFormsetLink =3D HiiFormsetNextLink; - continue; - } - - HiiFormLink =3D GetFirstNode (&HiiFormsetPrivate->HiiFormList); - while (!IsNull (&HiiFormsetPrivate->HiiFormList, HiiFormLink)) { - HiiNextFormLink =3D GetNextNode (&HiiFormsetPrivate->HiiFormList, Hi= iFormLink); - HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLi= nk); - - HiiStatementLink =3DGetFirstNode (&HiiFormPrivate->StatementList); - while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) { - HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementLi= st, HiiStatementLink); - HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LIN= K (HiiStatementLink); - - if (HiiStatementPrivate->Description !=3D 0) { - TmpString =3D HiiGetRedfishString (HiiFormsetPrivate->HiiHandle,= Schema, HiiStatementPrivate->Description); - if (TmpString !=3D NULL) { - Status =3D RegularExpressionProtocol->MatchString ( - RegularExpressionProtoco= l, - TmpString, - Pattern, - &gEfiRegexSyntaxTypePerl= Guid, - &IsMatch, - NULL, - &CaptureCount - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, MatchString \"%s\" failed: %r\n", = __FUNCTION__, Pattern, Status)); - ASSERT (FALSE); - return Status; - } - - // - // Found - // - if (IsMatch) { - StatementRef =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_= CONFIG_STATEMENT_PRIVATE_REF)); - if (StatementRef =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - StatementRef->Statement =3D HiiStatementPrivate; - InsertTailList (&StatementList->StatementList, &StatementRef= ->Link); - ++StatementList->Count; - } - - FreePool (TmpString); - } - } - - HiiStatementLink =3D HiiNextStatementLink; - } - - HiiFormLink =3D HiiNextFormLink; - } - - HiiFormsetLink =3D HiiFormsetNextLink; - } - - return EFI_SUCCESS; -} - -/** - Get statement private instance by the given configure language. - - @param[in] FormsetList Form-set list to search. - @param[in] Schema Schema to be matched. - @param[in] ConfigureLang Configure language. - - @retval REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * Pointer to stateme= nt private instance. - -**/ -REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * -GetStatementPrivateByConfigureLang ( - IN LIST_ENTRY *FormsetList, - IN CHAR8 *Schema, - IN EFI_STRING ConfigureLang - ) -{ - LIST_ENTRY *HiiFormsetLink; - LIST_ENTRY *HiiFormsetNextLink; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate; - LIST_ENTRY *HiiFormLink; - LIST_ENTRY *HiiNextFormLink; - REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate; - LIST_ENTRY *HiiStatementLink; - LIST_ENTRY *HiiNextStatementLink; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; - EFI_STRING TmpString; - - if (FormsetList =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRI= NG (ConfigureLang)) { - return NULL; - } - - if (IsListEmpty (FormsetList)) { - return NULL; - } - - HiiFormsetLink =3D GetFirstNode (FormsetList); - while (!IsNull (FormsetList, HiiFormsetLink)) { - HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - // - // Performance check. - // If there is no desired Redfish schema found, skip this formset. - // - if (!CheckSupportedSchema (&HiiFormsetPrivate->SupportedSchema, Schema= )) { - HiiFormsetLink =3D HiiFormsetNextLink; - continue; - } - - HiiFormLink =3D GetFirstNode (&HiiFormsetPrivate->HiiFormList); - while (!IsNull (&HiiFormsetPrivate->HiiFormList, HiiFormLink)) { - HiiNextFormLink =3D GetNextNode (&HiiFormsetPrivate->HiiFormList, Hi= iFormLink); - HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLi= nk); - - HiiStatementLink =3DGetFirstNode (&HiiFormPrivate->StatementList); - while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) { - HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementLi= st, HiiStatementLink); - HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LIN= K (HiiStatementLink); - - DEBUG_CODE ( - STATIC UINTN Index =3D 0; - DEBUG ((DEBUG_INFO, "%a, [%d] search %s in QID: 0x%x form: 0x%x = formset: %g\n", __FUNCTION__, ++Index, ConfigureLang, HiiStatementPrivate->= QuestionId, HiiFormPrivate->Id, &HiiFormsetPrivate->Guid)); - ); - - if (HiiStatementPrivate->Description !=3D 0) { - TmpString =3D HiiGetRedfishString (HiiFormsetPrivate->HiiHandle,= Schema, HiiStatementPrivate->Description); - if (TmpString !=3D NULL) { - if (StrCmp (TmpString, ConfigureLang) =3D=3D 0) { - FreePool (TmpString); - return HiiStatementPrivate; - } - - FreePool (TmpString); - } - } - - HiiStatementLink =3D HiiNextStatementLink; - } - - HiiFormLink =3D HiiNextFormLink; - } - - HiiFormsetLink =3D HiiFormsetNextLink; - } - - return NULL; -} - -/** - Get form-set private instance by the given HII handle. - - @param[in] HiiHandle HII handle instance. - @param[in] FormsetList Form-set list to search. - - @retval REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * Pointer to form-set= private instance. - -**/ -REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * -GetFormsetPrivateByHiiHandle ( - IN EFI_HII_HANDLE HiiHandle, - IN LIST_ENTRY *FormsetList - ) -{ - LIST_ENTRY *HiiFormsetLink; - LIST_ENTRY *HiiFormsetNextLink; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate; - - if (HiiHandle =3D=3D NULL || FormsetList =3D=3D NULL) { - return NULL; - } - - if (IsListEmpty (FormsetList)) { - return NULL; - } - - HiiFormsetLink =3D GetFirstNode (FormsetList); - while (!IsNull (FormsetList, HiiFormsetLink)) { - HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - if (HiiFormsetPrivate->HiiHandle =3D=3D HiiHandle) { - return HiiFormsetPrivate; - } - - HiiFormsetLink =3D HiiFormsetNextLink; - } - - return NULL; -} - -/** - Release formset and all the forms and statements that belong to this for= mset. - - @param[in] FormsetPrivate Pointer to HP_HII_FORM_SET_PRIVATE - - @retval EFI_STATUS - -**/ -EFI_STATUS -ReleaseFormset ( - IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate - ) -{ - LIST_ENTRY *HiiFormLink; - LIST_ENTRY *HiiNextFormLink; - REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate; - LIST_ENTRY *HiiStatementLink; - LIST_ENTRY *HiiNextStatementLink; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; - UINTN Index; - - if (FormsetPrivate =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - HiiFormLink =3D GetFirstNode (&FormsetPrivate->HiiFormList); - while (!IsNull (&FormsetPrivate->HiiFormList, HiiFormLink)) { - HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink= ); - HiiNextFormLink =3D GetNextNode (&FormsetPrivate->HiiFormList, HiiForm= Link); - - HiiStatementLink =3D GetFirstNode (&HiiFormPrivate->StatementList); - while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) { - HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK = (HiiStatementLink); - HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementList= , HiiStatementLink); - - // - // HiiStatementPrivate->HiiStatement will be released in DestroyForm= Set(). - // - - if (HiiStatementPrivate->DesStringCache !=3D NULL) { - FreePool (HiiStatementPrivate->DesStringCache); - HiiStatementPrivate->DesStringCache =3D NULL; - } - - RemoveEntryList (&HiiStatementPrivate->Link); - FreePool (HiiStatementPrivate); - HiiStatementLink =3D HiiNextStatementLink; - } - - // - // HiiStatementPrivate->HiiForm will be released in DestroyFormSet(). - // - - RemoveEntryList (&HiiFormPrivate->Link); - FreePool (HiiFormPrivate); - HiiFormLink =3D HiiNextFormLink; - } - - if (FormsetPrivate->HiiFormSet !=3D NULL) { - DestroyFormSet (FormsetPrivate->HiiFormSet); - FormsetPrivate->HiiFormSet =3D NULL; - } - - FreePool (FormsetPrivate->DevicePathStr); - - // - // Release schema list - // - if (FormsetPrivate->SupportedSchema.SchemaList !=3D NULL) { - for (Index =3D 0; Index < FormsetPrivate->SupportedSchema.Count; Index= ++) { - FreePool (FormsetPrivate->SupportedSchema.SchemaList[Index]); - } - - FreePool (FormsetPrivate->SupportedSchema.SchemaList); - FormsetPrivate->SupportedSchema.SchemaList =3D NULL; - FormsetPrivate->SupportedSchema.Count =3D 0; - } - - return EFI_SUCCESS; -} - -/** - Create new form-set instance. - - @retval REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * Pointer to newly cr= eated form-set private instance. - -**/ -REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * -NewFormsetPrivate ( - VOID - ) -{ - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *NewFormsetPrivate; - - NewFormsetPrivate =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_= FORM_SET_PRIVATE)); - if (NewFormsetPrivate =3D=3D NULL) { - return NULL; - } - - // - // Initial newly created formset private data. - // - InitializeListHead (&NewFormsetPrivate->HiiFormList); - - return NewFormsetPrivate; -} - -/** - Load the HII formset from the given HII handle. - - @param[in] HiiHandle Target HII handle to load. - @param[out] FormsetPrivate The formset private data. - - @retval EFI_STATUS - -**/ -EFI_STATUS -LoadFormset ( - IN EFI_HII_HANDLE HiiHandle, - OUT REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate - ) -{ - EFI_STATUS Status; - HII_FORMSET *HiiFormSet; - HII_FORM *HiiForm; - LIST_ENTRY *HiiFormLink; - REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate; - HII_STATEMENT *HiiStatement; - LIST_ENTRY *HiiStatementLink; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; - EFI_GUID ZeroGuid; - - if (HiiHandle =3D=3D NULL || FormsetPrivate =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - - HiiFormSet =3D AllocateZeroPool (sizeof (HII_FORMSET)); - if (HiiFormSet =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Find HII formset by the given HII handle. - // - ZeroMem (&ZeroGuid, sizeof (ZeroGuid)); - Status =3D CreateFormSetFromHiiHandle (HiiHandle, &ZeroGuid, HiiFormSet); - if (EFI_ERROR (Status) || IsListEmpty (&HiiFormSet->FormListHead)) { - Status =3D EFI_NOT_FOUND; - goto ErrorExit; - } - - // - // Initialize formset - // - InitializeFormSet (HiiFormSet); - - // - // Initialize formset private data. - // - FormsetPrivate->HiiFormSet =3D HiiFormSet; - FormsetPrivate->HiiHandle =3D HiiHandle; - CopyGuid (&FormsetPrivate->Guid, &HiiFormSet->Guid); - FormsetPrivate->DevicePathStr =3D ConvertDevicePathToText (HiiFormSet->D= evicePath, FALSE, FALSE); - Status =3D GetSupportedSchema (FormsetPrivate->HiiHandle, &FormsetPrivat= e->SupportedSchema); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "%a, No schema from HII handle: 0x%x found: %r\n",= __FUNCTION__, FormsetPrivate->HiiHandle, Status)); - } - - HiiFormLink =3D GetFirstNode (&HiiFormSet->FormListHead); - while (!IsNull (&HiiFormSet->FormListHead, HiiFormLink)) { - HiiForm =3D HII_FORM_FROM_LINK (HiiFormLink); - - HiiFormPrivate =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_F= ORM_PRIVATE)); - if (HiiFormPrivate =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto ErrorExit; - } - - // - // Initialize form private data. - // - HiiFormPrivate->HiiForm =3D HiiForm; - HiiFormPrivate->Id =3D HiiForm->FormId; - HiiFormPrivate->Title =3D HiiForm->FormTitle; - HiiFormPrivate->ParentFormset =3D FormsetPrivate; - InitializeListHead (&HiiFormPrivate->StatementList); - - HiiStatementLink =3D GetFirstNode (&HiiForm->StatementListHead); - while (!IsNull (&HiiForm->StatementListHead, HiiStatementLink)) { - HiiStatement =3D HII_STATEMENT_FROM_LINK (HiiStatementLink); - - HiiStatementPrivate =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_C= ONFIG_STATEMENT_PRIVATE)); - if (HiiStatementPrivate =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto ErrorExit; - } - // - // Initialize statement private data. - // - HiiStatementPrivate->HiiStatement =3D HiiStatement; - HiiStatementPrivate->QuestionId =3D HiiStatement->QuestionId; - HiiStatementPrivate->Description =3D HiiStatement->Prompt; - HiiStatementPrivate->ParentForm =3D HiiFormPrivate; - - // - // Attach to statement list. - // - InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate= ->Link); - HiiStatementLink =3D GetNextNode (&HiiForm->StatementListHead, HiiSt= atementLink); - } - // - // Attach to form list. - // - InsertTailList (&FormsetPrivate->HiiFormList, &HiiFormPrivate->Link); - HiiFormLink =3D GetNextNode (&HiiFormSet->FormListHead, HiiFormLink); - } - - return EFI_SUCCESS; - -ErrorExit: - - // - // Release HiiFormSet if HiiFormSet is not linked to FormsetPrivate yet. - // - if (HiiFormSet !=3D NULL && FormsetPrivate->HiiFormSet !=3D HiiFormSet) { - DestroyFormSet (HiiFormSet); - } - - // - // Release resource when error happens. - // - ReleaseFormset (FormsetPrivate); - - return Status; -} - -/** - Release formset list and all the forms that belong to this formset. - - @param[in] FormsetList Pointer to formst list that needs to be - released. - - @retval EFI_STATUS - -**/ -EFI_STATUS -LoadFormsetList ( - IN EFI_HII_HANDLE *HiiHandle, - OUT LIST_ENTRY *FormsetList - ) -{ - EFI_STATUS Status; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate; - - if (HiiHandle =3D=3D NULL || FormsetList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - FormsetPrivate =3D GetFormsetPrivateByHiiHandle (HiiHandle, FormsetList); - if (FormsetPrivate !=3D NULL) { - return EFI_ALREADY_STARTED; - } - - FormsetPrivate =3D NewFormsetPrivate (); - if (FormsetPrivate =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); - return EFI_OUT_OF_RESOURCES; - } - - // - // Load formset on the given HII handle. - // - Status =3D LoadFormset (HiiHandle, FormsetPrivate); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to load formset: %r\n", __FUNCTION__,= Status)); - FreePool (FormsetPrivate); - return Status; - } - - // - // Attach to cache list. - // - InsertTailList (FormsetList, &FormsetPrivate->Link); - - DEBUG_CODE ( - DumpFormsetList (FormsetList); - ); - - return EFI_SUCCESS; -} - -/** - Release formset list and all the forms that belong to this formset. - - @param[in] FormsetList Pointer to formst list that needs to be - released. - - @retval EFI_STATUS - -**/ -EFI_STATUS -ReleaseFormsetList ( - IN LIST_ENTRY *FormsetList - ) -{ - LIST_ENTRY *HiiFormsetLink; - LIST_ENTRY *HiiFormsetNextLink; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate; - - if (FormsetList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (IsListEmpty (FormsetList)) { - return EFI_SUCCESS; - } - - HiiFormsetLink =3D GetFirstNode (FormsetList); - while (!IsNull (FormsetList, HiiFormsetLink)) { - HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink); - HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink); - - // - // Detach from list. - // - RemoveEntryList (&HiiFormsetPrivate->Link); - ReleaseFormset (HiiFormsetPrivate); - FreePool (HiiFormsetPrivate); - HiiFormsetLink =3D HiiFormsetNextLink; - } - - return EFI_SUCCESS; -} - -/** - Get all pending list. - - @param[in] HiiHandle HII handle instance. - @param[in] PendingList Pending list to keep pending data. - - @retval REDFISH_PLATFORM_CONFIG_PENDING_LIST * Pointer to pending list= data. - -**/ -REDFISH_PLATFORM_CONFIG_PENDING_LIST * -GetPendingList ( - IN EFI_HII_HANDLE *HiiHandle, - IN LIST_ENTRY *PendingList - ) -{ - LIST_ENTRY *PendingListLink; - REDFISH_PLATFORM_CONFIG_PENDING_LIST *Target; - - if (HiiHandle =3D=3D NULL || PendingList =3D=3D NULL) { - return NULL; - } - - if (IsListEmpty (PendingList)) { - return NULL; - } - - PendingListLink =3D GetFirstNode (PendingList); - while (!IsNull (PendingList, PendingListLink)) { - Target =3D REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK (PendingList= Link); - - if (Target->HiiHandle =3D=3D HiiHandle) { - return Target; - } - - PendingListLink =3D GetNextNode (PendingList, PendingListLink); - } - - return NULL; -} - -/** - When HII database is updated. Keep updated HII handle into pending list = so - we can process them later. - - @param[in] HiiHandle HII handle instance. - @param[in] PendingList Pending list to keep HII handle which is recentl= y updated. - - @retval EFI_SUCCESS HII handle is saved in pending list. - @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -NotifyFormsetUpdate ( - IN EFI_HII_HANDLE *HiiHandle, - IN LIST_ENTRY *PendingList - ) -{ - REDFISH_PLATFORM_CONFIG_PENDING_LIST *TargetPendingList; - - if (HiiHandle =3D=3D NULL || PendingList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Check and see if this HII handle is processed already. - // - TargetPendingList =3D GetPendingList (HiiHandle, PendingList); - if (TargetPendingList !=3D NULL) { - TargetPendingList->IsDeleted =3D FALSE; - DEBUG_CODE ( - DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is updated\n", __FUNCTION__,= HiiHandle)); - ); - return EFI_SUCCESS; - } - - TargetPendingList=3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_P= ENDING_LIST)); - if (TargetPendingList =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - TargetPendingList->HiiHandle =3D HiiHandle; - TargetPendingList->IsDeleted =3D FALSE; - - InsertTailList (PendingList, &TargetPendingList->Link); - - DEBUG_CODE ( - DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is created\n", __FUNCTION__,= HiiHandle)); - ); - - return EFI_SUCCESS; -} - -/** - When HII database is updated and form-set is deleted. Keep deleted HII h= andle into pending list so - we can process them later. - - @param[in] HiiHandle HII handle instance. - @param[in] PendingList Pending list to keep HII handle which is recentl= y updated. - - @retval EFI_SUCCESS HII handle is saved in pending list. - @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -NotifyFormsetDeleted ( - IN EFI_HII_HANDLE *HiiHandle, - IN LIST_ENTRY *PendingList - ) -{ - REDFISH_PLATFORM_CONFIG_PENDING_LIST *TargetPendingList; - - if (HiiHandle =3D=3D NULL || PendingList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Check and see if this HII handle is processed already. - // - TargetPendingList =3D GetPendingList (HiiHandle, PendingList); - if (TargetPendingList !=3D NULL) { - TargetPendingList->IsDeleted =3D TRUE; - DEBUG_CODE ( - DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is updated and deleted\n",= __FUNCTION__, HiiHandle)); - ); - return EFI_SUCCESS; - } - - TargetPendingList=3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_P= ENDING_LIST)); - if (TargetPendingList =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - TargetPendingList->HiiHandle =3D HiiHandle; - TargetPendingList->IsDeleted =3D TRUE; - - InsertTailList (PendingList, &TargetPendingList->Link); - - DEBUG_CODE ( - DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is deleted\n", __FUNCTION__,= HiiHandle)); - ); - - return EFI_SUCCESS; -} - -/** - There are HII database update and we need to process them accordingly so= that we - won't use stale data. This function will parse updated HII handle again = in order - to get updated data-set. - - @param[in] FormsetList List to keep HII form-set. - @param[in] PendingList List to keep HII handle that is updated. - - @retval EFI_SUCCESS HII handle is saved in pending list. - @retval EFI_INVALID_PARAMETER FormsetList is NULL or PendingList is NU= LL. - -**/ -EFI_STATUS -ProcessPendingList ( - IN LIST_ENTRY *FormsetList, - IN LIST_ENTRY *PendingList - ) -{ - LIST_ENTRY *PendingListLink; - LIST_ENTRY *PendingListNextLink; - REDFISH_PLATFORM_CONFIG_PENDING_LIST *Target; - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate; - EFI_STATUS Status; - - - if (FormsetList =3D=3D NULL || PendingList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (IsListEmpty (PendingList)) { - return EFI_SUCCESS; - } - - PendingListLink =3D GetFirstNode (PendingList); - while (!IsNull (PendingList, PendingListLink)) { - PendingListNextLink =3D GetNextNode (PendingList, PendingListLink); - Target =3D REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK (PendingList= Link); - - if (Target->IsDeleted) { - // - // The HII resource on this HII handle is removed. Release the forms= et. - // - FormsetPrivate =3D GetFormsetPrivateByHiiHandle (Target->HiiHandle, = FormsetList); - if (FormsetPrivate !=3D NULL) { - DEBUG ((DEBUG_INFO, "%a, formset: %g is removed because driver rel= ease HII resource it already\n", __FUNCTION__, FormsetPrivate->Guid)); - RemoveEntryList (&FormsetPrivate->Link); - ReleaseFormset (FormsetPrivate); - FreePool (FormsetPrivate); - } else { - DEBUG ((DEBUG_WARN, "%a, formset on HII handle 0x%x was removed al= ready\n", __FUNCTION__, Target->HiiHandle)); - } - } else { - // - // The HII resource on this HII handle is updated/removed. - // - FormsetPrivate =3D GetFormsetPrivateByHiiHandle (Target->HiiHandle, = FormsetList); - if (FormsetPrivate !=3D NULL) { - // - // HII formset already exist, release it and query again. - // - DEBUG ((DEBUG_INFO, "%a, formset: %g is updated. Release current f= ormset\n", __FUNCTION__, &FormsetPrivate->Guid)); - RemoveEntryList (&FormsetPrivate->Link); - ReleaseFormset (FormsetPrivate); - FreePool (FormsetPrivate); - } - - Status =3D LoadFormsetList (Target->HiiHandle, FormsetList); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, load formset from HII handle: 0x%x faile= d: %r\n", __FUNCTION__, Target->HiiHandle, Status)); - } - } - - // - // Detach it from list first. - // - RemoveEntryList (&Target->Link); - FreePool (Target); - - PendingListLink =3D PendingListNextLink; - } - - return EFI_SUCCESS; -} - -/** - Release all resource in statement list. - - @param[in] StatementList Statement list to be released. - - @retval EFI_SUCCESS All resource are released. - @retval EFI_INVALID_PARAMETER StatementList is NULL. - -**/ -EFI_STATUS -ReleaseStatementList ( - IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList - ) -{ - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef; - LIST_ENTRY *NextLink; - - if (StatementList =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (IsListEmpty (&StatementList->StatementList)) { - return EFI_SUCCESS; - } - - NextLink =3D GetFirstNode (&StatementList->StatementList); - while (!IsNull (&StatementList->StatementList, NextLink)) { - StatementRef =3D REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK (Next= Link); - NextLink =3D GetNextNode (&StatementList->StatementList, NextLink); - - RemoveEntryList (&StatementRef->Link); - FreePool (StatementRef); - } - - return EFI_SUCCESS; -} +/** @file=0D +=0D + The implementation of EDKII Redfidh Platform Config Protocol.=0D +=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +#include "RedfishPlatformConfigDxe.h"=0D +#include "RedfishPlatformConfigImpl.h"=0D +=0D +extern REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate;=0D +=0D +/**=0D + Debug dump HII string=0D +=0D + @param[in] HiiHandle HII handle instance=0D + @param[in] StringId HII string to dump=0D +=0D + @retval EFI_SUCCESS Dump HII string successfully=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +DumpHiiString (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN EFI_STRING_ID StringId=0D + )=0D +{=0D + EFI_STRING String;=0D +=0D + if (HiiHandle =3D=3D NULL || StringId =3D=3D 0) {=0D + DEBUG ((DEBUG_INFO, "???"));=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + String =3D HiiGetString (HiiHandle, StringId, NULL);=0D + if (String =3D=3D NULL) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + DEBUG ((DEBUG_INFO, "%s", String));=0D + FreePool (String);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Debug dump HII form-set data=0D +=0D + @param[in] FormsetPrivate HII form-set private instance.=0D +=0D + @retval EFI_SUCCESS Dump form-set successfully=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +DumpFormset (=0D + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate=0D + )=0D +{=0D + LIST_ENTRY *HiiFormLink;=0D + LIST_ENTRY *HiiNextFormLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate;=0D + LIST_ENTRY *HiiStatementLink;=0D + LIST_ENTRY *HiiNextStatementLink;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate;=0D + UINTN Index;=0D +=0D + if (FormsetPrivate =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Index =3D 0;=0D + HiiFormLink =3D GetFirstNode (&FormsetPrivate->HiiFormList);=0D + while (!IsNull (&FormsetPrivate->HiiFormList, HiiFormLink)) {=0D + HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink= );=0D + HiiNextFormLink =3D GetNextNode (&FormsetPrivate->HiiFormList, HiiForm= Link);=0D +=0D + DEBUG ((DEBUG_INFO, " [%d] form: %d title: ", ++Index, HiiFormPrivate= ->Id));=0D + DumpHiiString (FormsetPrivate->HiiHandle, HiiFormPrivate->Title);=0D + DEBUG ((DEBUG_INFO, "\n"));=0D +=0D + HiiStatementLink =3D GetFirstNode (&HiiFormPrivate->StatementList);=0D + while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {=0D + HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK = (HiiStatementLink);=0D + HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementList= , HiiStatementLink);=0D +=0D + DEBUG ((DEBUG_INFO, " QID: 0x%x Prompt: ", HiiStatementPrivate->Q= uestionId));=0D + DumpHiiString (FormsetPrivate->HiiHandle, HiiStatementPrivate->Descr= iption);=0D + DEBUG ((DEBUG_INFO, "\n"));=0D +=0D + HiiStatementLink =3D HiiNextStatementLink;=0D + }=0D +=0D + HiiFormLink =3D HiiNextFormLink;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Debug dump HII form-set list=0D +=0D + @param[in] FormsetList Form-set list instance=0D +=0D + @retval EFI_SUCCESS Dump list successfully=0D + @retval Others Errors occur=0D +=0D +**/=0D +EFI_STATUS=0D +DumpFormsetList (=0D + IN LIST_ENTRY *FormsetList=0D + )=0D +{=0D + LIST_ENTRY *HiiFormsetLink;=0D + LIST_ENTRY *HiiFormsetNextLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate;=0D + UINTN Index;=0D +=0D + if (FormsetList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (IsListEmpty (FormsetList)) {=0D + DEBUG ((DEBUG_INFO, "%a, Empty formset list\n", __FUNCTION__));=0D + return EFI_SUCCESS;=0D + }=0D +=0D + Index =3D 0;=0D + HiiFormsetLink =3D GetFirstNode (FormsetList);=0D + while (!IsNull (FormsetList, HiiFormsetLink)) {=0D + HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + DEBUG ((DEBUG_INFO, "[%d] HII Handle: 0x%x formset: %g at %s\n", ++Ind= ex, HiiFormsetPrivate->HiiHandle, &HiiFormsetPrivate->Guid, HiiFormsetPriva= te->DevicePathStr));=0D + DumpFormset (HiiFormsetPrivate);=0D +=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Retrieves a string from a string package in a English language. The=0D + returned string is allocated using AllocatePool(). The caller is respon= sible=0D + for freeing the allocated buffer using FreePool().=0D +=0D + If HiiHandle is NULL, then ASSERT().=0D + If StringId is 0, then ASSET.=0D +=0D + @param[in] HiiStringProtocol EFI_HII_STRING_PROTOCOL instance.=0D + @param[in] HiiHandle A handle that was previously registered in= the HII Database.=0D + @param[in] StringId The identifier of the string to retrieved = from the string=0D + package associated with HiiHandle.=0D +=0D + @retval NULL The string specified by StringId is not present in the st= ring package.=0D + @retval Other The string was returned.=0D +=0D +**/=0D +EFI_STRING=0D +HiiGetRedfishString (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN CHAR8 *Language,=0D + IN EFI_STRING_ID StringId=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN StringSize;=0D + CHAR16 TempString;=0D + EFI_STRING String;=0D +=0D + if (mRedfishPlatformConfigPrivate->HiiString =3D=3D NULL || HiiHandle = =3D=3D NULL || StringId =3D=3D 0 || IS_EMPTY_STRING (Language)) {=0D + ASSERT (FALSE);=0D + return NULL;=0D + }=0D +=0D + //=0D + // Retrieve the size of the string in the string package for the BestLan= guage=0D + //=0D + StringSize =3D 0;=0D + Status =3D mRedfishPlatformConfigPrivate->HiiString->GetString (=0D + mRedfishPlatformConfigPrivate= ->HiiString,=0D + Language,=0D + HiiHandle,=0D + StringId,=0D + &TempString,=0D + &StringSize,=0D + NULL=0D + );=0D + //=0D + // If GetString() returns EFI_SUCCESS for a zero size,=0D + // then there are no supported languages registered for HiiHandle. If G= etString()=0D + // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is n= ot present=0D + // in the HII Database=0D + //=0D + if (Status !=3D EFI_BUFFER_TOO_SMALL) {=0D + return NULL;=0D + }=0D +=0D + //=0D + // Allocate a buffer for the return string=0D + //=0D + String =3D AllocateZeroPool (StringSize);=0D + if (String =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + //=0D + // Retrieve the string from the string package=0D + //=0D + Status =3D mRedfishPlatformConfigPrivate->HiiString->GetString (=0D + mRedfishPlatformConfigPrivate= ->HiiString,=0D + Language,=0D + HiiHandle,=0D + StringId,=0D + String,=0D + &StringSize,=0D + NULL=0D + );=0D + if (EFI_ERROR (Status)) {=0D + //=0D + // Free the buffer and return NULL if the supported languages can not = be retrieved.=0D + //=0D + FreePool (String);=0D + String =3D NULL;=0D + }=0D +=0D + //=0D + // Return the Null-terminated Unicode string=0D + //=0D + return String;=0D +}=0D +=0D +/**=0D + Retrieves a string from a string package in a English language. The=0D + returned string is allocated using AllocatePool(). The caller is respon= sible=0D + for freeing the allocated buffer using FreePool().=0D +=0D + If HiiHandle is NULL, then ASSERT().=0D + If StringId is 0, then ASSET.=0D +=0D + @param[in] HiiStringProtocol EFI_HII_STRING_PROTOCOL instance.=0D + @param[in] HiiHandle A handle that was previously registered in= the HII Database.=0D + @param[in] StringId The identifier of the string to retrieved = from the string=0D + package associated with HiiHandle.=0D +=0D + @retval NULL The string specified by StringId is not present in the st= ring package.=0D + @retval Other The string was returned.=0D +=0D +**/=0D +CHAR8 *=0D +HiiGetRedfishAsciiString (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN CHAR8 *Language,=0D + IN EFI_STRING_ID StringId=0D + )=0D +{=0D + EFI_STRING HiiString;=0D + UINTN StringSize;=0D + CHAR8 *AsciiString;=0D +=0D + HiiString =3D HiiGetRedfishString (HiiHandle, Language, StringId);=0D + if (HiiString =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, Can not find string ID: 0x%x with %a\n", __F= UNCTION__, StringId, Language));=0D + return NULL;=0D + }=0D +=0D + StringSize =3D (StrLen (HiiString) + 1) * sizeof (CHAR8);=0D + AsciiString =3D AllocatePool (StringSize);=0D + if (AsciiString =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + UnicodeStrToAsciiStrS (HiiString, AsciiString, StringSize);=0D +=0D + FreePool (HiiString);=0D + return AsciiString;=0D +}=0D +=0D +/**=0D + Get string from HII database in English language.=0D +=0D + @param[in] HiiHandle A handle that was previously registered in= the HII Database.=0D + @param[in] StringId The identifier of the string to retrieved = from the string=0D + package associated with HiiHandle.=0D +=0D + @retval NULL The string specified by StringId is not present in the st= ring package.=0D + @retval Other The string was returned.=0D +=0D +**/=0D +EFI_STRING=0D +HiiGetEnglishString (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN EFI_STRING_ID StringId=0D + )=0D +{=0D + return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId);= =0D +}=0D +=0D +/**=0D + Check and see if this is supported schema or not.=0D +=0D + @param[in] SupportedSchema The list of supported schema.=0D + @param[in] Schema Schema string to be checked.=0D +=0D + @retval BOOLEAN TRUE if this is supported schema. FALSE ot= herwise.=0D +=0D +**/=0D +BOOLEAN=0D +CheckSupportedSchema (=0D + IN REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema,=0D + IN CHAR8 *Schema=0D + )=0D +{=0D + UINTN Index;=0D +=0D + if (SupportedSchema =3D=3D NULL || IS_EMPTY_STRING (Schema)) {=0D + return FALSE;=0D + }=0D +=0D + if (SupportedSchema->Count =3D=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + for (Index =3D 0; Index < SupportedSchema->Count; Index++) {=0D + if (AsciiStrCmp (SupportedSchema->SchemaList[Index], Schema) =3D=3D 0)= {=0D + return TRUE;=0D + }=0D + }=0D +=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Get the list of supported schema from the given HII handle.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[out] SupportedSchema Supported schema on this HII handle.=0D +=0D + @retval EFI_SUCCESS Schema list is returned.=0D + @retval EFI_INVALID_PARAMETER HiiHandle is NULL or SupportedSchema is NU= LL.=0D + @retval EFI_NOT_FOUND No supported schema found.=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +GetSupportedSchema (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + OUT REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema=0D + )=0D +{=0D + CHAR8 *SupportedLanguages;=0D + UINTN Index;=0D + UINTN LangIndex;=0D + UINTN Count;=0D + UINTN StrSize;=0D + UINTN ListIndex;=0D +=0D + if (HiiHandle =3D=3D NULL || SupportedSchema =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + SupportedSchema->Count =3D 0;=0D +=0D + SupportedLanguages =3D HiiGetSupportedLanguages (HiiHandle);=0D + if (SupportedLanguages =3D=3D NULL) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + Index =3D 0;=0D + LangIndex =3D 0;=0D + Count =3D 0;=0D + while (TRUE) {=0D + if (SupportedLanguages[Index] =3D=3D ';' || SupportedLanguages[Index] = =3D=3D '\0') {=0D + if (AsciiStrnCmp (&SupportedLanguages[LangIndex], X_UEFI_SCHEMA_PREF= IX, AsciiStrLen (X_UEFI_SCHEMA_PREFIX)) =3D=3D 0) {=0D + ++Count;=0D + }=0D + LangIndex =3D Index + 1;=0D + }=0D +=0D + if (SupportedLanguages[Index] =3D=3D '\0') {=0D + break;=0D + }=0D +=0D + ++Index;=0D + }=0D +=0D + if (Count =3D=3D 0) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + SupportedSchema->Count =3D Count;=0D + SupportedSchema->SchemaList =3D AllocatePool (sizeof (CHAR8 *) * Count);= =0D + if (SupportedSchema->SchemaList =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + Index =3D 0;=0D + LangIndex =3D 0;=0D + ListIndex =3D 0;=0D + while (TRUE) {=0D +=0D + if (SupportedLanguages[Index] =3D=3D ';' || SupportedLanguages[Index] = =3D=3D '\0') {=0D + if (AsciiStrnCmp (&SupportedLanguages[LangIndex], X_UEFI_SCHEMA_PREF= IX, AsciiStrLen (X_UEFI_SCHEMA_PREFIX)) =3D=3D 0) {=0D + StrSize =3D Index - LangIndex;=0D + SupportedSchema->SchemaList[ListIndex] =3D AllocateCopyPool ((StrS= ize + 1), &SupportedLanguages[LangIndex]);=0D + SupportedSchema->SchemaList[ListIndex][StrSize] =3D '\0';=0D + ++ListIndex;=0D + }=0D +=0D + LangIndex =3D Index + 1;=0D + }=0D +=0D + if (SupportedLanguages[Index] =3D=3D '\0') {=0D + break;=0D + }=0D +=0D + ++Index;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Search and find statement private instance by given regular expression p= atthern=0D + which describes the Configure Language.=0D +=0D + @param[in] RegularExpressionProtocol Regular express protocol.=0D + @param[in] FormsetList Form-set list to search.=0D + @param[in] Schema Schema to be matched.=0D + @param[in] Pattern Regular expression pattern.=0D + @param[out] StatementList Statement list that match above = pattern.=0D +=0D + @retval EFI_SUCCESS Statement list is returned.=0D + @retval EFI_INVALID_PARAMETER Input parameter is NULL.=0D + @retval EFI_NOT_READY Regular express protocol is NULL.=0D + @retval EFI_NOT_FOUND No statement is found.=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +GetStatementPrivateByConfigureLangRegex (=0D + IN EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionPr= otocol,=0D + IN LIST_ENTRY *FormsetList,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING Pattern,=0D + OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList=0D + )=0D +{=0D + LIST_ENTRY *HiiFormsetLink;=0D + LIST_ENTRY *HiiFormsetNextLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate;=0D + LIST_ENTRY *HiiFormLink;=0D + LIST_ENTRY *HiiNextFormLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate;=0D + LIST_ENTRY *HiiStatementLink;=0D + LIST_ENTRY *HiiNextStatementLink;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate;=0D + EFI_STRING TmpString;=0D + UINTN CaptureCount;=0D + BOOLEAN IsMatch;=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef;=0D +=0D + if (FormsetList =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRI= NG (Pattern) || StatementList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (RegularExpressionProtocol =3D=3D NULL) {=0D + return EFI_NOT_READY;=0D + }=0D +=0D + StatementList->Count =3D 0;=0D + InitializeListHead (&StatementList->StatementList);=0D +=0D + if (IsListEmpty (FormsetList)) {=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + HiiFormsetLink =3D GetFirstNode (FormsetList);=0D + while (!IsNull (FormsetList, HiiFormsetLink)) {=0D + HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + //=0D + // Performance check.=0D + // If there is no desired Redfish schema found, skip this formset.=0D + //=0D + if (!CheckSupportedSchema (&HiiFormsetPrivate->SupportedSchema, Schema= )) {=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + continue;=0D + }=0D +=0D + HiiFormLink =3D GetFirstNode (&HiiFormsetPrivate->HiiFormList);=0D + while (!IsNull (&HiiFormsetPrivate->HiiFormList, HiiFormLink)) {=0D + HiiNextFormLink =3D GetNextNode (&HiiFormsetPrivate->HiiFormList, Hi= iFormLink);=0D + HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLi= nk);=0D +=0D + HiiStatementLink =3DGetFirstNode (&HiiFormPrivate->StatementList);=0D + while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {= =0D + HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementLi= st, HiiStatementLink);=0D + HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LIN= K (HiiStatementLink);=0D +=0D + if (HiiStatementPrivate->Description !=3D 0) {=0D + TmpString =3D HiiGetRedfishString (HiiFormsetPrivate->HiiHandle,= Schema, HiiStatementPrivate->Description);=0D + if (TmpString !=3D NULL) {=0D + Status =3D RegularExpressionProtocol->MatchString (=0D + RegularExpressionProtoco= l,=0D + TmpString,=0D + Pattern,=0D + &gEfiRegexSyntaxTypePerl= Guid,=0D + &IsMatch,=0D + NULL,=0D + &CaptureCount=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, MatchString \"%s\" failed: %r\n", = __FUNCTION__, Pattern, Status));=0D + ASSERT (FALSE);=0D + return Status;=0D + }=0D +=0D + //=0D + // Found=0D + //=0D + if (IsMatch) {=0D + StatementRef =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_= CONFIG_STATEMENT_PRIVATE_REF));=0D + if (StatementRef =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + StatementRef->Statement =3D HiiStatementPrivate;=0D + InsertTailList (&StatementList->StatementList, &StatementRef= ->Link);=0D + ++StatementList->Count;=0D + }=0D +=0D + FreePool (TmpString);=0D + }=0D + }=0D +=0D + HiiStatementLink =3D HiiNextStatementLink;=0D + }=0D +=0D + HiiFormLink =3D HiiNextFormLink;=0D + }=0D +=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get statement private instance by the given configure language.=0D +=0D + @param[in] FormsetList Form-set list to search.=0D + @param[in] Schema Schema to be matched.=0D + @param[in] ConfigureLang Configure language.=0D +=0D + @retval REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * Pointer to stateme= nt private instance.=0D +=0D +**/=0D +REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *=0D +GetStatementPrivateByConfigureLang (=0D + IN LIST_ENTRY *FormsetList,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING ConfigureLang=0D + )=0D +{=0D + LIST_ENTRY *HiiFormsetLink;=0D + LIST_ENTRY *HiiFormsetNextLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate;=0D + LIST_ENTRY *HiiFormLink;=0D + LIST_ENTRY *HiiNextFormLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate;=0D + LIST_ENTRY *HiiStatementLink;=0D + LIST_ENTRY *HiiNextStatementLink;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate;=0D + EFI_STRING TmpString;=0D +=0D + if (FormsetList =3D=3D NULL || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRI= NG (ConfigureLang)) {=0D + return NULL;=0D + }=0D +=0D + if (IsListEmpty (FormsetList)) {=0D + return NULL;=0D + }=0D +=0D + HiiFormsetLink =3D GetFirstNode (FormsetList);=0D + while (!IsNull (FormsetList, HiiFormsetLink)) {=0D + HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + //=0D + // Performance check.=0D + // If there is no desired Redfish schema found, skip this formset.=0D + //=0D + if (!CheckSupportedSchema (&HiiFormsetPrivate->SupportedSchema, Schema= )) {=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + continue;=0D + }=0D +=0D + HiiFormLink =3D GetFirstNode (&HiiFormsetPrivate->HiiFormList);=0D + while (!IsNull (&HiiFormsetPrivate->HiiFormList, HiiFormLink)) {=0D + HiiNextFormLink =3D GetNextNode (&HiiFormsetPrivate->HiiFormList, Hi= iFormLink);=0D + HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLi= nk);=0D +=0D + HiiStatementLink =3DGetFirstNode (&HiiFormPrivate->StatementList);=0D + while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {= =0D + HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementLi= st, HiiStatementLink);=0D + HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LIN= K (HiiStatementLink);=0D +=0D + DEBUG_CODE (=0D + STATIC UINTN Index =3D 0;=0D + DEBUG ((DEBUG_INFO, "%a, [%d] search %s in QID: 0x%x form: 0x%x = formset: %g\n", __FUNCTION__, ++Index, ConfigureLang, HiiStatementPrivate->= QuestionId, HiiFormPrivate->Id, &HiiFormsetPrivate->Guid));=0D + );=0D +=0D + if (HiiStatementPrivate->Description !=3D 0) {=0D + TmpString =3D HiiGetRedfishString (HiiFormsetPrivate->HiiHandle,= Schema, HiiStatementPrivate->Description);=0D + if (TmpString !=3D NULL) {=0D + if (StrCmp (TmpString, ConfigureLang) =3D=3D 0) {=0D + FreePool (TmpString);=0D + return HiiStatementPrivate;=0D + }=0D +=0D + FreePool (TmpString);=0D + }=0D + }=0D +=0D + HiiStatementLink =3D HiiNextStatementLink;=0D + }=0D +=0D + HiiFormLink =3D HiiNextFormLink;=0D + }=0D +=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + return NULL;=0D +}=0D +=0D +/**=0D + Get form-set private instance by the given HII handle.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[in] FormsetList Form-set list to search.=0D +=0D + @retval REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * Pointer to form-set= private instance.=0D +=0D +**/=0D +REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *=0D +GetFormsetPrivateByHiiHandle (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN LIST_ENTRY *FormsetList=0D + )=0D +{=0D + LIST_ENTRY *HiiFormsetLink;=0D + LIST_ENTRY *HiiFormsetNextLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate;=0D +=0D + if (HiiHandle =3D=3D NULL || FormsetList =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + if (IsListEmpty (FormsetList)) {=0D + return NULL;=0D + }=0D +=0D + HiiFormsetLink =3D GetFirstNode (FormsetList);=0D + while (!IsNull (FormsetList, HiiFormsetLink)) {=0D + HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + if (HiiFormsetPrivate->HiiHandle =3D=3D HiiHandle) {=0D + return HiiFormsetPrivate;=0D + }=0D +=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + return NULL;=0D +}=0D +=0D +/**=0D + Release formset and all the forms and statements that belong to this for= mset.=0D +=0D + @param[in] FormsetPrivate Pointer to HP_HII_FORM_SET_PRIVATE=0D +=0D + @retval EFI_STATUS=0D +=0D +**/=0D +EFI_STATUS=0D +ReleaseFormset (=0D + IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate=0D + )=0D +{=0D + LIST_ENTRY *HiiFormLink;=0D + LIST_ENTRY *HiiNextFormLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate;=0D + LIST_ENTRY *HiiStatementLink;=0D + LIST_ENTRY *HiiNextStatementLink;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate;=0D + UINTN Index;=0D +=0D + if (FormsetPrivate =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + HiiFormLink =3D GetFirstNode (&FormsetPrivate->HiiFormList);=0D + while (!IsNull (&FormsetPrivate->HiiFormList, HiiFormLink)) {=0D + HiiFormPrivate =3D REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink= );=0D + HiiNextFormLink =3D GetNextNode (&FormsetPrivate->HiiFormList, HiiForm= Link);=0D +=0D + HiiStatementLink =3D GetFirstNode (&HiiFormPrivate->StatementList);=0D + while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {=0D + HiiStatementPrivate =3D REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK = (HiiStatementLink);=0D + HiiNextStatementLink =3D GetNextNode (&HiiFormPrivate->StatementList= , HiiStatementLink);=0D +=0D + //=0D + // HiiStatementPrivate->HiiStatement will be released in DestroyForm= Set().=0D + //=0D +=0D + if (HiiStatementPrivate->DesStringCache !=3D NULL) {=0D + FreePool (HiiStatementPrivate->DesStringCache);=0D + HiiStatementPrivate->DesStringCache =3D NULL;=0D + }=0D +=0D + RemoveEntryList (&HiiStatementPrivate->Link);=0D + FreePool (HiiStatementPrivate);=0D + HiiStatementLink =3D HiiNextStatementLink;=0D + }=0D +=0D + //=0D + // HiiStatementPrivate->HiiForm will be released in DestroyFormSet().= =0D + //=0D +=0D + RemoveEntryList (&HiiFormPrivate->Link);=0D + FreePool (HiiFormPrivate);=0D + HiiFormLink =3D HiiNextFormLink;=0D + }=0D +=0D + if (FormsetPrivate->HiiFormSet !=3D NULL) {=0D + DestroyFormSet (FormsetPrivate->HiiFormSet);=0D + FormsetPrivate->HiiFormSet =3D NULL;=0D + }=0D +=0D + FreePool (FormsetPrivate->DevicePathStr);=0D +=0D + //=0D + // Release schema list=0D + //=0D + if (FormsetPrivate->SupportedSchema.SchemaList !=3D NULL) {=0D + for (Index =3D 0; Index < FormsetPrivate->SupportedSchema.Count; Index= ++) {=0D + FreePool (FormsetPrivate->SupportedSchema.SchemaList[Index]);=0D + }=0D +=0D + FreePool (FormsetPrivate->SupportedSchema.SchemaList);=0D + FormsetPrivate->SupportedSchema.SchemaList =3D NULL;=0D + FormsetPrivate->SupportedSchema.Count =3D 0;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Create new form-set instance.=0D +=0D + @retval REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * Pointer to newly cr= eated form-set private instance.=0D +=0D +**/=0D +REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *=0D +NewFormsetPrivate (=0D + VOID=0D + )=0D +{=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *NewFormsetPrivate;=0D +=0D + NewFormsetPrivate =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_= FORM_SET_PRIVATE));=0D + if (NewFormsetPrivate =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + //=0D + // Initial newly created formset private data.=0D + //=0D + InitializeListHead (&NewFormsetPrivate->HiiFormList);=0D +=0D + return NewFormsetPrivate;=0D +}=0D +=0D +/**=0D + Load the HII formset from the given HII handle.=0D +=0D + @param[in] HiiHandle Target HII handle to load.=0D + @param[out] FormsetPrivate The formset private data.=0D +=0D + @retval EFI_STATUS=0D +=0D +**/=0D +EFI_STATUS=0D +LoadFormset (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + OUT REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate=0D + )=0D +{=0D + EFI_STATUS Status;=0D + HII_FORMSET *HiiFormSet;=0D + HII_FORM *HiiForm;=0D + LIST_ENTRY *HiiFormLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *HiiFormPrivate;=0D + HII_STATEMENT *HiiStatement;=0D + LIST_ENTRY *HiiStatementLink;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate;=0D + EFI_GUID ZeroGuid;=0D +=0D + if (HiiHandle =3D=3D NULL || FormsetPrivate =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D +=0D + HiiFormSet =3D AllocateZeroPool (sizeof (HII_FORMSET));=0D + if (HiiFormSet =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + //=0D + // Find HII formset by the given HII handle.=0D + //=0D + ZeroMem (&ZeroGuid, sizeof (ZeroGuid));=0D + Status =3D CreateFormSetFromHiiHandle (HiiHandle, &ZeroGuid, HiiFormSet)= ;=0D + if (EFI_ERROR (Status) || IsListEmpty (&HiiFormSet->FormListHead)) {=0D + Status =3D EFI_NOT_FOUND;=0D + goto ErrorExit;=0D + }=0D +=0D + //=0D + // Initialize formset=0D + //=0D + InitializeFormSet (HiiFormSet);=0D +=0D + //=0D + // Initialize formset private data.=0D + //=0D + FormsetPrivate->HiiFormSet =3D HiiFormSet;=0D + FormsetPrivate->HiiHandle =3D HiiHandle;=0D + CopyGuid (&FormsetPrivate->Guid, &HiiFormSet->Guid);=0D + FormsetPrivate->DevicePathStr =3D ConvertDevicePathToText (HiiFormSet->D= evicePath, FALSE, FALSE);=0D + Status =3D GetSupportedSchema (FormsetPrivate->HiiHandle, &FormsetPrivat= e->SupportedSchema);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_WARN, "%a, No schema from HII handle: 0x%x found: %r\n",= __FUNCTION__, FormsetPrivate->HiiHandle, Status));=0D + }=0D +=0D + HiiFormLink =3D GetFirstNode (&HiiFormSet->FormListHead);=0D + while (!IsNull (&HiiFormSet->FormListHead, HiiFormLink)) {=0D + HiiForm =3D HII_FORM_FROM_LINK (HiiFormLink);=0D +=0D + HiiFormPrivate =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_F= ORM_PRIVATE));=0D + if (HiiFormPrivate =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto ErrorExit;=0D + }=0D +=0D + //=0D + // Initialize form private data.=0D + //=0D + HiiFormPrivate->HiiForm =3D HiiForm;=0D + HiiFormPrivate->Id =3D HiiForm->FormId;=0D + HiiFormPrivate->Title =3D HiiForm->FormTitle;=0D + HiiFormPrivate->ParentFormset =3D FormsetPrivate;=0D + InitializeListHead (&HiiFormPrivate->StatementList);=0D +=0D + HiiStatementLink =3D GetFirstNode (&HiiForm->StatementListHead);=0D + while (!IsNull (&HiiForm->StatementListHead, HiiStatementLink)) {=0D + HiiStatement =3D HII_STATEMENT_FROM_LINK (HiiStatementLink);=0D +=0D + HiiStatementPrivate =3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_C= ONFIG_STATEMENT_PRIVATE));=0D + if (HiiStatementPrivate =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto ErrorExit;=0D + }=0D + //=0D + // Initialize statement private data.=0D + //=0D + HiiStatementPrivate->HiiStatement =3D HiiStatement;=0D + HiiStatementPrivate->QuestionId =3D HiiStatement->QuestionId;=0D + HiiStatementPrivate->Description =3D HiiStatement->Prompt;=0D + HiiStatementPrivate->ParentForm =3D HiiFormPrivate;=0D +=0D + //=0D + // Attach to statement list.=0D + //=0D + InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate= ->Link);=0D + HiiStatementLink =3D GetNextNode (&HiiForm->StatementListHead, HiiSt= atementLink);=0D + }=0D + //=0D + // Attach to form list.=0D + //=0D + InsertTailList (&FormsetPrivate->HiiFormList, &HiiFormPrivate->Link);= =0D + HiiFormLink =3D GetNextNode (&HiiFormSet->FormListHead, HiiFormLink);= =0D + }=0D +=0D + return EFI_SUCCESS;=0D +=0D +ErrorExit:=0D +=0D + //=0D + // Release HiiFormSet if HiiFormSet is not linked to FormsetPrivate yet.= =0D + //=0D + if (HiiFormSet !=3D NULL && FormsetPrivate->HiiFormSet !=3D HiiFormSet) = {=0D + DestroyFormSet (HiiFormSet);=0D + }=0D +=0D + //=0D + // Release resource when error happens.=0D + //=0D + ReleaseFormset (FormsetPrivate);=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Release formset list and all the forms that belong to this formset.=0D +=0D + @param[in] FormsetList Pointer to formst list that needs to be=0D + released.=0D +=0D + @retval EFI_STATUS=0D +=0D +**/=0D +EFI_STATUS=0D +LoadFormsetList (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + OUT LIST_ENTRY *FormsetList=0D + )=0D +{=0D + EFI_STATUS Status;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate;=0D +=0D + if (HiiHandle =3D=3D NULL || FormsetList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + FormsetPrivate =3D GetFormsetPrivateByHiiHandle (HiiHandle, FormsetList)= ;=0D + if (FormsetPrivate !=3D NULL) {=0D + return EFI_ALREADY_STARTED;=0D + }=0D +=0D + FormsetPrivate =3D NewFormsetPrivate ();=0D + if (FormsetPrivate =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__));=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + //=0D + // Load formset on the given HII handle.=0D + //=0D + Status =3D LoadFormset (HiiHandle, FormsetPrivate);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to load formset: %r\n", __FUNCTION__,= Status));=0D + FreePool (FormsetPrivate);=0D + return Status;=0D + }=0D +=0D + //=0D + // Attach to cache list.=0D + //=0D + InsertTailList (FormsetList, &FormsetPrivate->Link);=0D +=0D + DEBUG_CODE (=0D + DumpFormsetList (FormsetList);=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Release formset list and all the forms that belong to this formset.=0D +=0D + @param[in] FormsetList Pointer to formst list that needs to be=0D + released.=0D +=0D + @retval EFI_STATUS=0D +=0D +**/=0D +EFI_STATUS=0D +ReleaseFormsetList (=0D + IN LIST_ENTRY *FormsetList=0D + )=0D +{=0D + LIST_ENTRY *HiiFormsetLink;=0D + LIST_ENTRY *HiiFormsetNextLink;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *HiiFormsetPrivate;=0D +=0D + if (FormsetList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (IsListEmpty (FormsetList)) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + HiiFormsetLink =3D GetFirstNode (FormsetList);=0D + while (!IsNull (FormsetList, HiiFormsetLink)) {=0D + HiiFormsetNextLink =3D GetNextNode (FormsetList, HiiFormsetLink);=0D + HiiFormsetPrivate =3D REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFo= rmsetLink);=0D +=0D + //=0D + // Detach from list.=0D + //=0D + RemoveEntryList (&HiiFormsetPrivate->Link);=0D + ReleaseFormset (HiiFormsetPrivate);=0D + FreePool (HiiFormsetPrivate);=0D + HiiFormsetLink =3D HiiFormsetNextLink;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get all pending list.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[in] PendingList Pending list to keep pending data.=0D +=0D + @retval REDFISH_PLATFORM_CONFIG_PENDING_LIST * Pointer to pending list= data.=0D +=0D +**/=0D +REDFISH_PLATFORM_CONFIG_PENDING_LIST *=0D +GetPendingList (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + IN LIST_ENTRY *PendingList=0D + )=0D +{=0D + LIST_ENTRY *PendingListLink;=0D + REDFISH_PLATFORM_CONFIG_PENDING_LIST *Target;=0D +=0D + if (HiiHandle =3D=3D NULL || PendingList =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + if (IsListEmpty (PendingList)) {=0D + return NULL;=0D + }=0D +=0D + PendingListLink =3D GetFirstNode (PendingList);=0D + while (!IsNull (PendingList, PendingListLink)) {=0D + Target =3D REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK (PendingList= Link);=0D +=0D + if (Target->HiiHandle =3D=3D HiiHandle) {=0D + return Target;=0D + }=0D +=0D + PendingListLink =3D GetNextNode (PendingList, PendingListLink);=0D + }=0D +=0D + return NULL;=0D +}=0D +=0D +/**=0D + When HII database is updated. Keep updated HII handle into pending list = so=0D + we can process them later.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[in] PendingList Pending list to keep HII handle which is recentl= y updated.=0D +=0D + @retval EFI_SUCCESS HII handle is saved in pending list.=0D + @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL= .=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +NotifyFormsetUpdate (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + IN LIST_ENTRY *PendingList=0D + )=0D +{=0D + REDFISH_PLATFORM_CONFIG_PENDING_LIST *TargetPendingList;=0D +=0D + if (HiiHandle =3D=3D NULL || PendingList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + //=0D + // Check and see if this HII handle is processed already.=0D + //=0D + TargetPendingList =3D GetPendingList (HiiHandle, PendingList);=0D + if (TargetPendingList !=3D NULL) {=0D + TargetPendingList->IsDeleted =3D FALSE;=0D + DEBUG_CODE (=0D + DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is updated\n", __FUNCTION__,= HiiHandle));=0D + );=0D + return EFI_SUCCESS;=0D + }=0D +=0D + TargetPendingList=3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_P= ENDING_LIST));=0D + if (TargetPendingList =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + TargetPendingList->HiiHandle =3D HiiHandle;=0D + TargetPendingList->IsDeleted =3D FALSE;=0D +=0D + InsertTailList (PendingList, &TargetPendingList->Link);=0D +=0D + DEBUG_CODE (=0D + DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is created\n", __FUNCTION__,= HiiHandle));=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + When HII database is updated and form-set is deleted. Keep deleted HII h= andle into pending list so=0D + we can process them later.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[in] PendingList Pending list to keep HII handle which is recentl= y updated.=0D +=0D + @retval EFI_SUCCESS HII handle is saved in pending list.=0D + @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL= .=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +NotifyFormsetDeleted (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + IN LIST_ENTRY *PendingList=0D + )=0D +{=0D + REDFISH_PLATFORM_CONFIG_PENDING_LIST *TargetPendingList;=0D +=0D + if (HiiHandle =3D=3D NULL || PendingList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + //=0D + // Check and see if this HII handle is processed already.=0D + //=0D + TargetPendingList =3D GetPendingList (HiiHandle, PendingList);=0D + if (TargetPendingList !=3D NULL) {=0D + TargetPendingList->IsDeleted =3D TRUE;=0D + DEBUG_CODE (=0D + DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is updated and deleted\n",= __FUNCTION__, HiiHandle));=0D + );=0D + return EFI_SUCCESS;=0D + }=0D +=0D + TargetPendingList=3D AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_P= ENDING_LIST));=0D + if (TargetPendingList =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + TargetPendingList->HiiHandle =3D HiiHandle;=0D + TargetPendingList->IsDeleted =3D TRUE;=0D +=0D + InsertTailList (PendingList, &TargetPendingList->Link);=0D +=0D + DEBUG_CODE (=0D + DEBUG ((DEBUG_INFO, "%a, HII handle: 0x%x is deleted\n", __FUNCTION__,= HiiHandle));=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + There are HII database update and we need to process them accordingly so= that we=0D + won't use stale data. This function will parse updated HII handle again = in order=0D + to get updated data-set.=0D +=0D + @param[in] FormsetList List to keep HII form-set.=0D + @param[in] PendingList List to keep HII handle that is updated.=0D +=0D + @retval EFI_SUCCESS HII handle is saved in pending list.=0D + @retval EFI_INVALID_PARAMETER FormsetList is NULL or PendingList is NU= LL.=0D +=0D +**/=0D +EFI_STATUS=0D +ProcessPendingList (=0D + IN LIST_ENTRY *FormsetList,=0D + IN LIST_ENTRY *PendingList=0D + )=0D +{=0D + LIST_ENTRY *PendingListLink;=0D + LIST_ENTRY *PendingListNextLink;=0D + REDFISH_PLATFORM_CONFIG_PENDING_LIST *Target;=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate;=0D + EFI_STATUS Status;=0D +=0D +=0D + if (FormsetList =3D=3D NULL || PendingList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (IsListEmpty (PendingList)) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + PendingListLink =3D GetFirstNode (PendingList);=0D + while (!IsNull (PendingList, PendingListLink)) {=0D + PendingListNextLink =3D GetNextNode (PendingList, PendingListLink);=0D + Target =3D REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK (PendingList= Link);=0D +=0D + if (Target->IsDeleted) {=0D + //=0D + // The HII resource on this HII handle is removed. Release the forms= et.=0D + //=0D + FormsetPrivate =3D GetFormsetPrivateByHiiHandle (Target->HiiHandle, = FormsetList);=0D + if (FormsetPrivate !=3D NULL) {=0D + DEBUG ((DEBUG_INFO, "%a, formset: %g is removed because driver rel= ease HII resource it already\n", __FUNCTION__, FormsetPrivate->Guid));=0D + RemoveEntryList (&FormsetPrivate->Link);=0D + ReleaseFormset (FormsetPrivate);=0D + FreePool (FormsetPrivate);=0D + } else {=0D + DEBUG ((DEBUG_WARN, "%a, formset on HII handle 0x%x was removed al= ready\n", __FUNCTION__, Target->HiiHandle));=0D + }=0D + } else {=0D + //=0D + // The HII resource on this HII handle is updated/removed.=0D + //=0D + FormsetPrivate =3D GetFormsetPrivateByHiiHandle (Target->HiiHandle, = FormsetList);=0D + if (FormsetPrivate !=3D NULL) {=0D + //=0D + // HII formset already exist, release it and query again.=0D + //=0D + DEBUG ((DEBUG_INFO, "%a, formset: %g is updated. Release current f= ormset\n", __FUNCTION__, &FormsetPrivate->Guid));=0D + RemoveEntryList (&FormsetPrivate->Link);=0D + ReleaseFormset (FormsetPrivate);=0D + FreePool (FormsetPrivate);=0D + }=0D +=0D + Status =3D LoadFormsetList (Target->HiiHandle, FormsetList);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, load formset from HII handle: 0x%x faile= d: %r\n", __FUNCTION__, Target->HiiHandle, Status));=0D + }=0D + }=0D +=0D + //=0D + // Detach it from list first.=0D + //=0D + RemoveEntryList (&Target->Link);=0D + FreePool (Target);=0D +=0D + PendingListLink =3D PendingListNextLink;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Release all resource in statement list.=0D +=0D + @param[in] StatementList Statement list to be released.=0D +=0D + @retval EFI_SUCCESS All resource are released.=0D + @retval EFI_INVALID_PARAMETER StatementList is NULL.=0D +=0D +**/=0D +EFI_STATUS=0D +ReleaseStatementList (=0D + IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList=0D + )=0D +{=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef;=0D + LIST_ENTRY *NextLink;=0D +=0D + if (StatementList =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (IsListEmpty (&StatementList->StatementList)) {=0D + return EFI_SUCCESS;=0D + }=0D +=0D + NextLink =3D GetFirstNode (&StatementList->StatementList);=0D + while (!IsNull (&StatementList->StatementList, NextLink)) {=0D + StatementRef =3D REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK (Next= Link);=0D + NextLink =3D GetNextNode (&StatementList->StatementList, NextLink);=0D +=0D + RemoveEntryList (&StatementRef->Link);=0D + FreePool (StatementRef);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.= h b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h index e0ba0fb2d3..4ffe52e4da 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h @@ -1,274 +1,298 @@ -/** @file - This file defines the EDKII Redfish Platform Config Protocol interface. - - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef EDKII_REDFISH_PLATFORM_CONFIG_IMPL_H_ -#define EDKII_REDFISH_PLATFORM_CONFIG_IMPL_H_ - -#include - -// -// Libraries -// -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define REDFISH_PLATFORM_CONFIG_DELETE_EXPIRED_FORMSET 0x00 -#define IS_EMPTY_STRING(a) (a =3D=3D NULL ||= a[0] =3D=3D L'\0') -#define ENGLISH_LANGUAGE_CODE "en-US" -#define X_UEFI_SCHEMA_PREFIX "x-uefi-redfish-" - -// -// Definition of REDFISH_PLATFORM_CONFIG_PRIVATE. -// -typedef struct { - LIST_ENTRY Link; - EFI_HII_HANDLE HiiHandle; - BOOLEAN IsDeleted; -} REDFISH_PLATFORM_CONFIG_PENDING_LIST; - -#define REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK(a) BASE_CR (a, RED= FISH_PLATFORM_CONFIG_PENDING_LIST, Link) - -typedef struct { - UINTN Count; // Number of schema in list - CHAR8 **SchemaList; // Schema list -} REDFISH_PLATFORM_CONFIG_SCHEMA; - -// -// Definition of REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE -// -typedef struct { - LIST_ENTRY Link; - HII_FORMSET *HiiFormSet; // Pointer to HII forms= et data. - EFI_GUID Guid; // Formset GUID. - EFI_HII_HANDLE HiiHandle; // Hii Handle of this f= ormset. - LIST_ENTRY HiiFormList; // Form list that keep = form data under this formset. - CHAR16 *DevicePathStr; // Device path of this = formset. - REDFISH_PLATFORM_CONFIG_SCHEMA SupportedSchema; // Schema that is suppo= rted in this formset. -} REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE; - -#define REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK(a) BASE_CR (a, REDFISH_= PLATFORM_CONFIG_FORM_SET_PRIVATE, Link) - -// -// Definition of REDFISH_PLATFORM_CONFIG_FORM_PRIVATE -// -typedef struct { - LIST_ENTRY Link; - UINT16 Id; // Form ID. - EFI_STRING_ID Title; // String toke= n of form title. - REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *ParentFormset; - HII_FORM *HiiForm; // Pointer to = HII form data. - LIST_ENTRY StatementList; // Statement l= ist that keep statement under this form. -} REDFISH_PLATFORM_CONFIG_FORM_PRIVATE; - -#define REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK(a) BASE_CR (a, REDFISH_PLA= TFORM_CONFIG_FORM_PRIVATE, Link) - -// -// 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. -} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE; - -#define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a) BASE_CR (a, REDFIS= H_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link) - -// -// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF -// -typedef struct { - LIST_ENTRY Link; - REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement; -} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF; - -#define REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK(a) BASE_CR (a, RE= DFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF, Link) - -// -// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST -// -typedef struct { - LIST_ENTRY StatementList; // List of REDFISH_PLATFORM_CONFIG_STA= TEMENT_PRIVATE_REF - UINTN Count; -} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST; - -/** - Release formset list and all the forms that belong to this formset. - - @param[in] FormsetList Pointer to formst list that needs to be - released. - - @retval EFI_STATUS - -**/ -EFI_STATUS -ReleaseFormsetList ( - IN LIST_ENTRY *FormsetList - ); - -/** - Release formset list and all the forms that belong to this formset. - - @param[in] FormsetList Pointer to formst list that needs to be - released. - - @retval EFI_STATUS - -**/ -EFI_STATUS -LoadFormsetList ( - IN EFI_HII_HANDLE *HiiHandle, - OUT LIST_ENTRY *FormsetList - ); - -/** - When HII database is updated. Keep updated HII handle into pending list = so - we can process them later. - - @param[in] HiiHandle HII handle instance. - @param[in] PendingList Pending list to keep HII handle which is recentl= y updated. - - @retval EFI_SUCCESS HII handle is saved in pending list. - @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -NotifyFormsetUpdate ( - IN EFI_HII_HANDLE *HiiHandle, - IN LIST_ENTRY *PendingList - ); - -/** - When HII database is updated and form-set is deleted. Keep deleted HII h= andle into pending list so - we can process them later. - - @param[in] HiiHandle HII handle instance. - @param[in] PendingList Pending list to keep HII handle which is recentl= y updated. - - @retval EFI_SUCCESS HII handle is saved in pending list. - @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -NotifyFormsetDeleted ( - IN EFI_HII_HANDLE *HiiHandle, - IN LIST_ENTRY *PendingList - ); - -/** - Get statement private instance by the given configure language. - - @param[in] FormsetList Form-set list to search. - @param[in] Schema Schema to be matched. - @param[in] ConfigureLang Configure language. - - @retval REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * Pointer to stateme= nt private instance. - -**/ -REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * -GetStatementPrivateByConfigureLang ( - IN LIST_ENTRY *FormsetList, - IN CHAR8 *Schema, - IN EFI_STRING ConfigureLang - ); - -/** - Search and find statement private instance by given regular expression p= atthern - which describes the Configure Language. - - @param[in] RegularExpressionProtocol Regular express protocol. - @param[in] FormsetList Form-set list to search. - @param[in] Schema Schema to be matched. - @param[in] Pattern Regular expression pattern. - @param[out] StatementList Statement list that match above = pattern. - - @retval EFI_SUCCESS Statement list is returned. - @retval EFI_INVALID_PARAMETER Input parameter is NULL. - @retval EFI_NOT_READY Regular express protocol is NULL. - @retval EFI_NOT_FOUND No statement is found. - @retval EFI_OUT_OF_RESOURCES System is out of memory. - -**/ -EFI_STATUS -GetStatementPrivateByConfigureLangRegex ( - IN EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionPr= otocol, - IN LIST_ENTRY *FormsetList, - IN CHAR8 *Schema, - IN EFI_STRING Pattern, - OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList - ); - -/** - There are HII database update and we need to process them accordingly so= that we - won't use stale data. This function will parse updated HII handle again = in order - to get updated data-set. - - @param[in] FormsetList List to keep HII form-set. - @param[in] PendingList List to keep HII handle that is updated. - - @retval EFI_SUCCESS HII handle is saved in pending list. - @retval EFI_INVALID_PARAMETER FormsetList is NULL or PendingList is NU= LL. - -**/ -EFI_STATUS -ProcessPendingList ( - IN LIST_ENTRY *FormsetList, - IN LIST_ENTRY *PendingList - ); - -/** - Retrieves a string from a string package in a English language. The - returned string is allocated using AllocatePool(). The caller is respon= sible - for freeing the allocated buffer using FreePool(). - - If HiiHandle is NULL, then ASSERT(). - If StringId is 0, then ASSET. - - @param[in] HiiStringProtocol EFI_HII_STRING_PROTOCOL instance. - @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. - -**/ -EFI_STRING -HiiGetRedfishString ( - IN EFI_HII_HANDLE HiiHandle, - IN CHAR8 *Language, - IN EFI_STRING_ID StringId - ); - -/** - Release all resource in statement list. - - @param[in] StatementList Statement list to be released. - - @retval EFI_SUCCESS All resource are released. - @retval EFI_INVALID_PARAMETER StatementList is NULL. - -**/ -EFI_STATUS -ReleaseStatementList ( - IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList - ); - -#endif +/** @file=0D + This file defines the EDKII Redfish Platform Config Protocol interface.= =0D +=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef EDKII_REDFISH_PLATFORM_CONFIG_IMPL_H_=0D +#define EDKII_REDFISH_PLATFORM_CONFIG_IMPL_H_=0D +=0D +#include =0D +=0D +//=0D +// Libraries=0D +//=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define REDFISH_PLATFORM_CONFIG_DELETE_EXPIRED_FORMSET 0x00=0D +#define IS_EMPTY_STRING(a) (a =3D=3D NULL ||= a[0] =3D=3D L'\0')=0D +#define ENGLISH_LANGUAGE_CODE "en-US"=0D +#define X_UEFI_SCHEMA_PREFIX "x-uefi-redfish-"= =0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_PRIVATE.=0D +//=0D +typedef struct {=0D + LIST_ENTRY Link;=0D + EFI_HII_HANDLE HiiHandle;=0D + BOOLEAN IsDeleted;=0D +} REDFISH_PLATFORM_CONFIG_PENDING_LIST;=0D +=0D +#define REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK(a) BASE_CR (a, RED= FISH_PLATFORM_CONFIG_PENDING_LIST, Link)=0D +=0D +typedef struct {=0D + UINTN Count; // Number of schema in lis= t=0D + CHAR8 **SchemaList; // Schema list=0D +} REDFISH_PLATFORM_CONFIG_SCHEMA;=0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE=0D +//=0D +typedef struct {=0D + LIST_ENTRY Link;=0D + HII_FORMSET *HiiFormSet; // Pointer to HII forms= et data.=0D + EFI_GUID Guid; // Formset GUID.=0D + EFI_HII_HANDLE HiiHandle; // Hii Handle of this f= ormset.=0D + LIST_ENTRY HiiFormList; // Form list that keep = form data under this formset.=0D + CHAR16 *DevicePathStr; // Device path of this = formset.=0D + REDFISH_PLATFORM_CONFIG_SCHEMA SupportedSchema; // Schema that is suppo= rted in this formset.=0D +} REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE;=0D +=0D +#define REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK(a) BASE_CR (a, REDFISH_= PLATFORM_CONFIG_FORM_SET_PRIVATE, Link)=0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_FORM_PRIVATE=0D +//=0D +typedef struct {=0D + LIST_ENTRY Link;=0D + UINT16 Id; // Form ID.=0D + EFI_STRING_ID Title; // String toke= n of form title.=0D + REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *ParentFormset;=0D + HII_FORM *HiiForm; // Pointer to = HII form data.=0D + LIST_ENTRY StatementList; // Statement l= ist that keep statement under this form.=0D +} REDFISH_PLATFORM_CONFIG_FORM_PRIVATE;=0D +=0D +#define REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK(a) BASE_CR (a, REDFISH_PLA= TFORM_CONFIG_FORM_PRIVATE, Link)=0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE=0D +//=0D +typedef struct {=0D + LIST_ENTRY Link;=0D + REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *ParentForm;=0D + HII_STATEMENT *HiiStatement; // Pointer to HII = statement data.=0D + EFI_QUESTION_ID QuestionId; // Question ID of = this statement.=0D + EFI_STRING_ID Description; // String token of= this question.=0D + EFI_STRING DesStringCache; // The string cach= e for search function.=0D +} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE;=0D +=0D +#define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a) BASE_CR (a, REDFIS= H_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link)=0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF=0D +//=0D +typedef struct {=0D + LIST_ENTRY Link;=0D + REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *Statement;=0D +} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF;=0D +=0D +#define REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK(a) BASE_CR (a, RE= DFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF, Link)=0D +=0D +//=0D +// Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST=0D +//=0D +typedef struct {=0D + LIST_ENTRY StatementList; // List of REDFISH_PLATFORM_CONFIG_STA= TEMENT_PRIVATE_REF=0D + UINTN Count;=0D +} REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST;=0D +=0D +/**=0D + Release formset list and all the forms that belong to this formset.=0D +=0D + @param[in] FormsetList Pointer to formst list that needs to be=0D + released.=0D +=0D + @retval EFI_STATUS=0D +=0D +**/=0D +EFI_STATUS=0D +ReleaseFormsetList (=0D + IN LIST_ENTRY *FormsetList=0D + );=0D +=0D +/**=0D + Release formset list and all the forms that belong to this formset.=0D +=0D + @param[in] FormsetList Pointer to formst list that needs to be=0D + released.=0D +=0D + @retval EFI_STATUS=0D +=0D +**/=0D +EFI_STATUS=0D +LoadFormsetList (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + OUT LIST_ENTRY *FormsetList=0D + );=0D +=0D +/**=0D + When HII database is updated. Keep updated HII handle into pending list = so=0D + we can process them later.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[in] PendingList Pending list to keep HII handle which is recentl= y updated.=0D +=0D + @retval EFI_SUCCESS HII handle is saved in pending list.=0D + @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL= .=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +NotifyFormsetUpdate (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + IN LIST_ENTRY *PendingList=0D + );=0D +=0D +/**=0D + When HII database is updated and form-set is deleted. Keep deleted HII h= andle into pending list so=0D + we can process them later.=0D +=0D + @param[in] HiiHandle HII handle instance.=0D + @param[in] PendingList Pending list to keep HII handle which is recentl= y updated.=0D +=0D + @retval EFI_SUCCESS HII handle is saved in pending list.=0D + @retval EFI_INVALID_PARAMETER HiiHnalde is NULL or PendingList is NULL= .=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +NotifyFormsetDeleted (=0D + IN EFI_HII_HANDLE *HiiHandle,=0D + IN LIST_ENTRY *PendingList=0D + );=0D +=0D +/**=0D + Get statement private instance by the given configure language.=0D +=0D + @param[in] FormsetList Form-set list to search.=0D + @param[in] Schema Schema to be matched.=0D + @param[in] ConfigureLang Configure language.=0D +=0D + @retval REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * Pointer to stateme= nt private instance.=0D +=0D +**/=0D +REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *=0D +GetStatementPrivateByConfigureLang (=0D + IN LIST_ENTRY *FormsetList,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING ConfigureLang=0D + );=0D +=0D +/**=0D + Search and find statement private instance by given regular expression p= atthern=0D + which describes the Configure Language.=0D +=0D + @param[in] RegularExpressionProtocol Regular express protocol.=0D + @param[in] FormsetList Form-set list to search.=0D + @param[in] Schema Schema to be matched.=0D + @param[in] Pattern Regular expression pattern.=0D + @param[out] StatementList Statement list that match above = pattern.=0D +=0D + @retval EFI_SUCCESS Statement list is returned.=0D + @retval EFI_INVALID_PARAMETER Input parameter is NULL.=0D + @retval EFI_NOT_READY Regular express protocol is NULL.=0D + @retval EFI_NOT_FOUND No statement is found.=0D + @retval EFI_OUT_OF_RESOURCES System is out of memory.=0D +=0D +**/=0D +EFI_STATUS=0D +GetStatementPrivateByConfigureLangRegex (=0D + IN EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionPr= otocol,=0D + IN LIST_ENTRY *FormsetList,=0D + IN CHAR8 *Schema,=0D + IN EFI_STRING Pattern,=0D + OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList=0D + );=0D +=0D +/**=0D + There are HII database update and we need to process them accordingly so= that we=0D + won't use stale data. This function will parse updated HII handle again = in order=0D + to get updated data-set.=0D +=0D + @param[in] FormsetList List to keep HII form-set.=0D + @param[in] PendingList List to keep HII handle that is updated.=0D +=0D + @retval EFI_SUCCESS HII handle is saved in pending list.=0D + @retval EFI_INVALID_PARAMETER FormsetList is NULL or PendingList is NU= LL.=0D +=0D +**/=0D +EFI_STATUS=0D +ProcessPendingList (=0D + IN LIST_ENTRY *FormsetList,=0D + IN LIST_ENTRY *PendingList=0D + );=0D +=0D +/**=0D + Retrieves a string from a string package in a English language. The=0D + returned string is allocated using AllocatePool(). The caller is respon= sible=0D + for freeing the allocated buffer using FreePool().=0D +=0D + If HiiHandle is NULL, then ASSERT().=0D + If StringId is 0, then ASSET.=0D +=0D + @param[in] HiiStringProtocol EFI_HII_STRING_PROTOCOL instance.=0D + @param[in] HiiHandle A handle that was previously registered in= the HII Database.=0D + @param[in] StringId The identifier of the string to retrieved = from the string=0D + package associated with HiiHandle.=0D +=0D + @retval NULL The string specified by StringId is not present in the st= ring package.=0D + @retval Other The string was returned.=0D +=0D +**/=0D +EFI_STRING=0D +HiiGetRedfishString (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN CHAR8 *Language,=0D + IN EFI_STRING_ID StringId=0D + );=0D +=0D +/**=0D + Retrieves a string from a string package in a English language. The=0D + returned string is allocated using AllocatePool(). The caller is respon= sible=0D + for freeing the allocated buffer using FreePool().=0D +=0D + If HiiHandle is NULL, then ASSERT().=0D + If StringId is 0, then ASSET.=0D +=0D + @param[in] HiiStringProtocol EFI_HII_STRING_PROTOCOL instance.=0D + @param[in] HiiHandle A handle that was previously registered in= the HII Database.=0D + @param[in] StringId The identifier of the string to retrieved = from the string=0D + package associated with HiiHandle.=0D +=0D + @retval NULL The string specified by StringId is not present in the st= ring package.=0D + @retval Other The string was returned.=0D +=0D +**/=0D +CHAR8 *=0D +HiiGetRedfishAsciiString (=0D + IN EFI_HII_HANDLE HiiHandle,=0D + IN CHAR8 *Language,=0D + IN EFI_STRING_ID StringId=0D + );=0D +=0D +/**=0D + Release all resource in statement list.=0D +=0D + @param[in] StatementList Statement list to be released.=0D +=0D + @retval EFI_SUCCESS All resource are released.=0D + @retval EFI_INVALID_PARAMETER StatementList is NULL.=0D +=0D +**/=0D +EFI_STATUS=0D +ReleaseStatementList (=0D + IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList=0D + );=0D +=0D +#endif=0D --=20 2.32.0.windows.2