Thank you so much for your help to review my patch files. Will address comments and push them to edk2-staging repo.
Nickle -----Original Message----- From: Chang, Abner <abner.ch...@amd.com> Sent: Thursday, July 28, 2022 11:48 AM To: Wang, Nickle (Server BIOS) <nickle.w...@hpe.com>; devel@edk2.groups.io Cc: Yang, Atom <atom.y...@amd.com>; Nick Ramirez <nrami...@nvidia.com> Subject: RE: [edk2-staging][PATCH v3 15/15] edk2-staging/RedfishClientPkg: Introduce Bios feature driver [AMD Official Use Only - General] Reviewed-by: Abner Chang <abner.ch...@amd.com> > -----Original Message----- > From: Nickle Wang <nickle.w...@hpe.com> > Sent: Wednesday, July 27, 2022 9:38 AM > To: devel@edk2.groups.io > Cc: Chang, Abner <abner.ch...@amd.com>; Yang, Atom > <atom.y...@amd.com>; Nick Ramirez <nrami...@nvidia.com> > Subject: [edk2-staging][PATCH v3 15/15] edk2-staging/RedfishClientPkg: > Introduce Bios feature driver > > [CAUTION: External Email] > > Introduce new feature driver to support Bios version 1.0.9 schema. > Update corresponding FDF and DSC file to enable this feature driver. > > Signed-off-by: Nickle Wang <nickle.w...@hpe.com> > Cc: Abner Chang <abner.ch...@amd.com> > Cc: Yang Atom <atom.y...@amd.com> > Cc: Nick Ramirez <nrami...@nvidia.com> > --- > .../Features/Bios/v1_0_9/Common/BiosCommon.c | 741 > ++++++++++++++++ > .../Features/Bios/v1_0_9/Common/BiosCommon.h | 30 + > .../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 789 ++++++++++++++++++ > .../Features/Bios/v1_0_9/Dxe/BiosDxe.inf | 52 ++ > RedfishClientPkg/RedfishClient.fdf.inc | 2 + > .../RedfishClientComponents.dsc.inc | 2 + > RedfishClientPkg/RedfishClientLibs.dsc.inc | 6 +- > 7 files changed, 1621 insertions(+), 1 deletion(-) > create mode 100644 > RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > create mode 100644 > RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h > create mode 100644 RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > create mode 100644 > RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > new file mode 100644 > index 0000000000..d910d0d8a9 > --- /dev/null > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c > @@ -0,0 +1,741 @@ > +/** @file > + Redfish feature driver implementation - common functions > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "BiosCommon.h" > + > +CHAR8 BiosEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\": > \"#Bios.v1_0_9.Bios\", \"Id\": \"\", \"Name\": \"\", \"Attributes\":{}}"; > + > +REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = > NULL; > + > +/** > + Consume resource from given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + @param[in] HeaderEtag The Etag string returned in HTTP header. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishConsumeResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *Json, > + IN CHAR8 *HeaderEtag OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + EFI_REDFISH_BIOS_V1_0_9 *Bios; > + EFI_REDFISH_BIOS_V1_0_9_CS *BiosCs; > + EFI_STRING ConfigureLang; > + RedfishCS_Type_EmptyProp_CS_Data *EmptyPropCs; > + > + > + if (Private == NULL || IS_EMPTY_STRING (Json)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Bios = NULL; > + BiosCs = NULL; > + ConfigureLang = NULL; > + > + Status = Private->JsonStructProtocol->ToStructure ( > + Private->JsonStructProtocol, > + NULL, > + Json, > + (EFI_REST_JSON_STRUCTURE_HEADER > **)&Bios > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", > __FUNCTION__, Status)); > + return Status; > + } > + > + BiosCs = Bios->Bios; > + > + // > + // Check ETAG to see if we need to consume it > + // > + if (CheckEtag (Private->Uri, HeaderEtag, BiosCs->odata_etag)) { > + // > + // No change > + // > + DEBUG ((DEBUG_INFO, "%a, ETAG: %s has no change, ignore consume > action\n", __FUNCTION__, Private->Uri)); > + Status = EFI_ALREADY_STARTED; > + goto ON_RELEASE; > + } > + > + // > + // Handle ATTRIBUTEREGISTRY > + // > + if (BiosCs->AttributeRegistry != NULL) { > + // > + // Find corresponding configure language for collection resource. > + // > + ConfigureLang = GetConfigureLang (BiosCs->odata_id, > "AttributeRegistry"); > + if (ConfigureLang != NULL) { > + Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, ConfigureLang, BiosCs->AttributeRegistry); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: > %s\n", __FUNCTION__, Private->Uri)); > + } > + } > + > + // > + // Handle ATTRIBUTES > + // > + if (BiosCs->Attributes == NULL) { > + BiosCs->Attributes = AllocateZeroPool (sizeof > (RedfishBios_V1_0_9_Attributes_CS)); > + ASSERT (BiosCs->Attributes != NULL); > + } > + > + // > + // Handle ATTRIBUTES->EmptyProperty > + // > + if (BiosCs->Attributes != NULL) { > + // > + // Validate empty property. > + // > + if (BiosCs->Attributes->Prop.ForwardLink == &BiosCs->Attributes->Prop) > { > + goto ON_RELEASE; > + } > + EmptyPropCs = (RedfishCS_Type_EmptyProp_CS_Data *)BiosCs- > >Attributes->Prop.ForwardLink; > + if (EmptyPropCs->Header.ResourceType == RedfishCS_Type_JSON) { > + DEBUG ((DEBUG_ERROR, "%a, Empty property with > RedfishCS_Type_JSON type resource is not supported yet. (%s)\n", > __FUNCTION__, Private->Uri)); > + goto ON_RELEASE; > + } > + // > + // Find corresponding configure language for collection resource. > + // > + ConfigureLang = GetConfigureLang (BiosCs->odata_id, "Attributes"); > + if (ConfigureLang != NULL) { > + Status = ApplyFeatureSettingsVagueType (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, ConfigureLang, EmptyPropCs->KeyValuePtr, > EmptyPropCs->NunmOfProperties); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: > %s\n", __FUNCTION__, Private->Uri)); > + } > + } > + > + > +ON_RELEASE: > + > + // > + // Release resource. > + // > + Private->JsonStructProtocol->DestoryStructure ( > + Private->JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)Bios > + ); > + > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +ProvisioningBiosProperties ( > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, > + IN CHAR8 *InputJson, > + IN CHAR8 *ResourceId, OPTIONAL > + IN EFI_STRING ConfigureLang, > + IN BOOLEAN ProvisionMode, > + OUT CHAR8 **ResultJson > + ) > +{ > + EFI_REDFISH_BIOS_V1_0_9 *Bios; > + EFI_REDFISH_BIOS_V1_0_9_CS *BiosCs; > + EFI_STATUS Status; > + BOOLEAN PropertyChanged; > + CHAR8 *AsciiStringValue; > + RedfishCS_EmptyProp_KeyValue *PropertyVagueValues; > + UINT32 VagueValueNumber; > + > + > + > + if (JsonStructProtocol == NULL || ResultJson == NULL || > IS_EMPTY_STRING (InputJson) || IS_EMPTY_STRING (ConfigureLang)) { > + return EFI_INVALID_PARAMETER; > + } > + > + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n", > __FUNCTION__, ConfigureLang, (ProvisionMode ? L"Provision resource" : > L"Update resource"))); > + > + *ResultJson = NULL; > + PropertyChanged = FALSE; > + > + Bios = NULL; > + Status = JsonStructProtocol->ToStructure ( > + JsonStructProtocol, > + NULL, > + InputJson, > + (EFI_REST_JSON_STRUCTURE_HEADER **)&Bios > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, ToStructure failure: %r\n", __FUNCTION__, > Status)); > + return Status; > + } > + > + BiosCs = Bios->Bios; > + > + // > + // ID > + // > + if (BiosCs->Id == NULL && !IS_EMPTY_STRING (ResourceId)) { > + BiosCs->Id = AllocateCopyPool (AsciiStrSize (ResourceId), ResourceId); > + } > + > + // > + // Handle ATTRIBUTEREGISTRY > + // > + if (PropertyChecker (BiosCs->AttributeRegistry, ProvisionMode)) { > + AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"AttributeRegistry", ConfigureLang); > + if (AsciiStringValue != NULL) { > + if (ProvisionMode || AsciiStrCmp (BiosCs->AttributeRegistry, > AsciiStringValue) != 0) { > + BiosCs->AttributeRegistry = AsciiStringValue; > + PropertyChanged = TRUE; > + } > + } > + } > + // > + // Handle ATTRIBUTES > + // > + if (BiosCs->Attributes != NULL) { > + // > + // Handle ATTRIBUTES > + // > + if (PropertyChecker (BiosCs->Attributes, ProvisionMode)) { > + PropertyVagueValues = GetPropertyVagueValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"Attributes", ConfigureLang, > &VagueValueNumber); > + if (PropertyVagueValues != NULL) { > + if (ProvisionMode || !CompareRedfishPropertyVagueValues ( > + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs- > >Attributes->Prop.ForwardLink)->KeyValuePtr, > + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs- > >Attributes->Prop.ForwardLink)->NunmOfProperties, > + PropertyVagueValues, > + VagueValueNumber)) { > + // > + // Use the properties on system to replace the one on Redfish > service. > + // > + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs->Attributes- > >Prop.ForwardLink)->KeyValuePtr = PropertyVagueValues; > + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs->Attributes- > >Prop.ForwardLink)->NunmOfProperties = VagueValueNumber; > + PropertyChanged = TRUE; > + } > + } > + } > + } > + > + > + // > + // Convert C structure back to JSON text. > + // > + Status = JsonStructProtocol->ToJson ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)Bios, > + ResultJson > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, ToJson() failed: %r\n", __FUNCTION__, > Status)); > + return Status; > + } > + > + // > + // Release resource. > + // > + JsonStructProtocol->DestoryStructure ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)Bios > + ); > + > + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); > +} > + > +EFI_STATUS > +ProvisioningBiosResource ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN UINTN Index, > + IN EFI_STRING ConfigureLang > + ) > +{ > + CHAR8 *Json; > + EFI_STATUS Status; > + EFI_STRING NewResourceLocation; > + CHAR8 *EtagStr; > + CHAR8 ResourceId[16]; > + > + if (IS_EMPTY_STRING (ConfigureLang) || Private == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + EtagStr = NULL; > + AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); > + > + Status = ProvisioningBiosProperties ( > + Private->JsonStructProtocol, > + BiosEmptyJson, > + ResourceId, > + ConfigureLang, > + TRUE, > + &Json > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, provisioning resource for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + return Status; > + } > + > + Status = CreatePayloadToPostResource (Private->RedfishService, Private- > >Payload, Json, &NewResourceLocation, &EtagStr); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + goto RELEASE_RESOURCE; > + } > + > + ASSERT (NewResourceLocation != NULL); > + > + // > + // Keep location of new resource. > + // > + if (NewResourceLocation != NULL) { > + RedfisSetRedfishUri (ConfigureLang, NewResourceLocation); > + } > + > + // > + // Handle Etag > + // > + if (EtagStr != NULL) { > + SetEtagWithUri (EtagStr, NewResourceLocation); > + FreePool (EtagStr); > + } > + > +RELEASE_RESOURCE: > + > + if (NewResourceLocation != NULL) { > + FreePool (NewResourceLocation); > + } > + > + if (Json != NULL) { > + FreePool (Json); > + } > + > + return Status; > +} > + > +EFI_STATUS > +ProvisioningBiosResources ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private > + ) > +{ > + UINTN Index; > + EFI_STATUS Status; > + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST > UnifiedConfigureLangList; > + > + if (Private == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang > (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, > REDPATH_ARRAY_PATTERN, &UnifiedConfigureLangList); > + if (EFI_ERROR (Status) || UnifiedConfigureLangList.Count == 0) { > + DEBUG ((DEBUG_ERROR, "%a, No HII question found with configure > language: %s: %r\n", __FUNCTION__, REDPATH_ARRAY_PATTERN, Status)); > + return EFI_NOT_FOUND; > + } > + // > + // Set the configuration language in the > RESOURCE_INFORMATION_EXCHANGE. > + // This information is sent back to the parent resource (e.g. the > collection > driver). > + // > + EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList); > + > + for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) { > + DEBUG ((DEBUG_INFO, "[%d] create Bios resource from: %s\n", > UnifiedConfigureLangList.List[Index].Index, > UnifiedConfigureLangList.List[Index].ConfigureLang)); > + ProvisioningBiosResource (Private, > UnifiedConfigureLangList.List[Index].Index, > UnifiedConfigureLangList.List[Index].ConfigureLang); > + FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang); > + } > + > + return EFI_SUCCESS; > +} > + > + > +EFI_STATUS > +ProvisioningBiosExistResource ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private > + ) > +{ > + EFI_STATUS Status; > + EFI_STRING ConfigureLang; > + CHAR8 *EtagStr; > + CHAR8 *Json; > + > + if (Private == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + EtagStr = NULL; > + Json = NULL; > + ConfigureLang = NULL; > + > + ConfigureLang = RedfishGetConfigLanguage (Private->Uri); > + if (ConfigureLang == NULL) { > + return EFI_NOT_FOUND; > + } > + > + Status = ProvisioningBiosProperties ( > + Private->JsonStructProtocol, > + BiosEmptyJson, > + NULL, > + ConfigureLang, > + TRUE, > + &Json > + ); > + if (EFI_ERROR (Status)) { > + if (Status == EFI_NOT_FOUND) { > + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource > for %s ignored. Nothing changed\n", __FUNCTION__, ConfigureLang)); > + } else { > + DEBUG ((DEBUG_ERROR, "%a, provisioning existing resource for %s > failed: %r\n", __FUNCTION__, ConfigureLang, Status)); > + } > + goto ON_RELEASE; > + } > + > + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for > %s\n", __FUNCTION__, ConfigureLang)); > + // > + // PUT back to instance > + // > + Status = CreatePayloadToPatchResource (Private->RedfishService, Private- > >Payload, Json, &EtagStr); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + } > + > + // > + // Handle Etag > + // > + if (EtagStr != NULL) { > + SetEtagWithUri (EtagStr, Private->Uri); > + FreePool (EtagStr); > + } > + > +ON_RELEASE: > + > + if (Json != NULL) { > + FreePool (Json); > + } > + > + if (ConfigureLang != NULL) { > + FreePool (ConfigureLang); > + } > + > + return Status; > +} > + > +/** > + Provisioning redfish resource by given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL > instance. > + @param[in] ResourceExist TRUE if resource exists, PUT method will > be > used. > + FALSE if resource does not exist POST > method is used. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishProvisioningResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN BOOLEAN ResourceExist > + ) > +{ > + if (Private == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + return (ResourceExist ? ProvisioningBiosExistResource (Private) : > ProvisioningBiosResources (Private)); > +} > + > +/** > + Check resource from given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishCheckResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *Json > + ) > +{ > + UINTN Index; > + EFI_STATUS Status; > + EFI_STRING *ConfigureLangList; > + UINTN Count; > + EFI_STRING Property; > + > + if (Private == NULL || IS_EMPTY_STRING (Json)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, > &ConfigureLangList, &Count); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, > BiosConfigToRedfishGetConfigureLangRegex failed: %r\n", __FUNCTION__, > Status)); > + return Status; > + } > + > + if (Count == 0) { > + return EFI_NOT_FOUND; > + } > + > + Status = EFI_SUCCESS; > + for (Index = 0; Index < Count; Index++) { > + > + Property = GetPropertyFromConfigureLang (Private->Uri, > ConfigureLangList[Index]); > + if (Property == NULL) { > + continue; > + } > + > + DEBUG ((DEBUG_INFO, "%a, [%d] check attribute for: %s\n", > __FUNCTION__, Index, Property)); > + if (!MatchPropertyWithJsonContext (Property, Json)) { > + DEBUG ((DEBUG_INFO, "%a, property is missing: %s\n", __FUNCTION__, > Property)); > + Status = EFI_NOT_FOUND; > + } > + } > + > + FreePool (ConfigureLangList); > + > + return Status; > +} > + > +/** > + Update resource to given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishUpdateResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *InputJson > + ) > +{ > + EFI_STATUS Status; > + CHAR8 *Json; > + EFI_STRING ConfigureLang; > + CHAR8 *EtagStr; > + > + if (Private == NULL || IS_EMPTY_STRING (InputJson)) { > + return EFI_INVALID_PARAMETER; > + } > + > + EtagStr = NULL; > + Json = NULL; > + ConfigureLang = NULL; > + > + ConfigureLang = RedfishGetConfigLanguage (Private->Uri); > + if (ConfigureLang == NULL) { > + return EFI_NOT_FOUND; > + } > + > + Status = ProvisioningBiosProperties ( > + Private->JsonStructProtocol, > + InputJson, > + NULL, > + ConfigureLang, > + FALSE, > + &Json > + ); > + if (EFI_ERROR (Status)) { > + if (Status == EFI_NOT_FOUND) { > + DEBUG ((REDFISH_DEBUG_TRACE, "%a, update resource for %s ignored. > Nothing changed\n", __FUNCTION__, ConfigureLang)); > + } else { > + DEBUG ((DEBUG_ERROR, "%a, update resource for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + } > + goto ON_RELEASE; > + } > + > + DEBUG ((REDFISH_DEBUG_TRACE, "%a, update resource for %s\n", > __FUNCTION__, ConfigureLang)); > + // > + // PUT back to instance > + // > + Status = CreatePayloadToPatchResource (Private->RedfishService, Private- > >Payload, Json, &EtagStr); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", > __FUNCTION__, ConfigureLang, Status)); > + } > + > + // > + // Handle Etag > + // > + if (EtagStr != NULL) { > + SetEtagWithUri (EtagStr, Private->Uri); > + FreePool (EtagStr); > + } > + > +ON_RELEASE: > + > + if (Json != NULL) { > + FreePool (Json); > + } > + > + if (ConfigureLang != NULL) { > + FreePool (ConfigureLang); > + } > + > + return Status; > +} > + > +/** > + Identify resource from given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishIdentifyResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *Json > + ) > +{ > + BOOLEAN Supported; > + EFI_STATUS Status; > + EFI_STRING EndOfChar; > + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList; > + > + Supported = RedfishIdentifyResource (Private->Uri, Private->Json); > + if (Supported) { > + Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang > (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, > REDPATH_ARRAY_PATTERN, &ConfigLangList); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, > BiosConfigToRedfishGetConfigureLangRegex failed: %r\n", __FUNCTION__, > Status)); > + return Status; > + } > + > + if (ConfigLangList.Count == 0) { > + return EFI_SUCCESS; > + } > + > + //EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}"); > + Status = IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL, > &EndOfChar); > + if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { > + ASSERT (FALSE); > + return EFI_DEVICE_ERROR; > + } > + if (Status != EFI_SUCCESS) { > + // > + // This is not the collection redpath. > + // > + GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0, > &EndOfChar); > + } > + *(++EndOfChar) = '\0'; > + // > + // Keep URI and ConfigLang mapping > + // > + RedfisSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private->Uri); > + // > + // Set the configuration language in the > RESOURCE_INFORMATION_EXCHANGE. > + // This information is sent back to the parent resource (e.g. the > collection > driver). > + // > + EdkIIRedfishResourceSetConfigureLang (&ConfigLangList); > + DestroyConfiglanguageList (&ConfigLangList); > + return EFI_SUCCESS; > + } > + > + return EFI_UNSUPPORTED; > +} > + > +EFI_STATUS > +HandleResource ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN EFI_STRING Uri > + ) > +{ > + EFI_STATUS Status; > + REDFISH_SCHEMA_INFO SchemaInfo; > + EFI_STRING ConfigLang; > + > + if (Private == NULL || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Resource match > + // > + > + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n", > __FUNCTION__, Uri)); > + > + Status = GetRedfishSchemaInfo (Private->RedfishService, Private- > >JsonStructProtocol, Uri, &SchemaInfo); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %s > %r\n", __FUNCTION__, Uri, Status)); > + return Status; > + } > + // > + // Check and see if this is target resource that we want to handle. > + // Some resource is handled by other provider so we have to make sure > this first. > + // > + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__, > Uri)); > + ConfigLang = RedfishGetConfigLanguage (Uri); > + if (ConfigLang == NULL) { > + Status = EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Private- > >InformationExchange); > + if (EFI_ERROR (Status)) { > + if (Status == EFI_UNSUPPORTED) { > + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n", > __FUNCTION__, Uri)); > + return EFI_SUCCESS; > + } > + > + DEBUG ((DEBUG_ERROR, "%a, fail to identify resource: \"%s\": %r\n", > __FUNCTION__, Uri, Status)); > + return Status; > + } > + } else { > + DEBUG ((REDFISH_DEBUG_TRACE, "%a, history record found: %s\n", > __FUNCTION__, ConfigLang)); > + FreePool (ConfigLang); > + } > + > + // > + // Check and see if target property exist or not even when collection > memeber exists. > + // If not, we sill do provision. > + // > + DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __FUNCTION__, > Uri)); > + Status = EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); > + if (EFI_ERROR (Status)) { > + // > + // The target property does not exist, do the provision to create > property. > + // > + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", > __FUNCTION__, Uri)); > + Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, > Private->InformationExchange, FALSE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", > __FUNCTION__, Status)); > + } > + > + return Status; > + } > + > + // > + // Consume first. > + // > + DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", > __FUNCTION__, Uri)); > + Status = EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %s: %r\n", > __FUNCTION__, Uri, Status)); > + } > + > + // > + // Patch. > + // > + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__, > Uri)); > + Status = EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n", > __FUNCTION__, Uri, Status)); > + } > + > + return Status; > +} > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h > b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h > new file mode 100644 > index 0000000000..321ded7637 > --- /dev/null > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h > @@ -0,0 +1,30 @@ > +/** @file > + > + Redfish feature driver implementation - internal header file > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef EFI_REDFISH_BIOS_COMMON_H_ > +#define EFI_REDFISH_BIOS_COMMON_H_ > + > +#include <RedfishJsonStructure/Bios/v1_0_9/EfiBiosV1_0_9.h> > +#include <RedfishResourceCommon.h> > + > +// > +// Schema information. > +// > +#define REDFISH_MANAGED_URI L"Systems/{}/Bios" > +#define MAX_URI_LENGTH 256 > +#define RESOURCE_SCHEMA "Bios" > +#define RESOURCE_SCHEMA_MAJOR "1" > +#define RESOURCE_SCHEMA_MINOR "0" > +#define RESOURCE_SCHEMA_ERRATA "9" > +#define RESOURCE_SCHEMA_VERSION "v1_0_9" > +#define REDPATH_ARRAY_PATTERN L"/Bios/.*" > +#define REDPATH_ARRAY_PREFIX L"/Bios/" > +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish-Bios.v1_0_9" > +#define REDFISH_SCHEMA_NAME "ComputerSystem" > + > +#endif > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > new file mode 100644 > index 0000000000..a478061cde > --- /dev/null > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c > @@ -0,0 +1,789 @@ > +/** @file > + Redfish feature driver implementation - Bios > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "../Common/BiosCommon.h" > + > +extern REDFISH_RESOURCE_COMMON_PRIVATE > *mRedfishResourcePrivate; > + > +EFI_STATUS > +HandleResource ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN EFI_STRING Uri > + ); > + > +EFI_HANDLE medfishResourceConfigProtocolHandle; > + > +/** > + Provising redfish resource by given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL > instance. > + @param[in] Uri Target URI to create resource. > + @param[in] PostMode TRUE if the resource does not exist, post > method is used. > + FALSE if the resource exist but property > is missing, put > method is used. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishResourceProvisioningResource ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri, > + IN BOOLEAN PostMode > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if (This == NULL || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + DEBUG ((DEBUG_INFO, "%a, provisioning in %s mode\n", __FUNCTION__, > (PostMode ? L"POST" : L"PATCH"))); > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTO > COL (This); > + > + if (Private->RedfishService == NULL) { > + return EFI_NOT_READY; > + } > + > + Status = GetResourceByUri (Private->RedfishService, Uri, &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", > __FUNCTION__, Uri)); > + return Status; > + } > + > + Private->Uri = Uri; > + Private->Payload = Response.Payload; > + ASSERT (Private->Payload != NULL); > + > + Status = RedfishProvisioningResourceCommon (Private, !PostMode); > + > + // > + // Release resource > + // > + if (Private->Payload != NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + Private->Payload = NULL; > + } > + > + return Status; > +} > + > +/** > + Consume resource from given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL > instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishResourceConsumeResource ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + CHAR8 *Etag; > + > + if (This == NULL || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTO > COL (This); > + > + if (Private->RedfishService == NULL) { > + return EFI_NOT_READY; > + } > + > + Status = GetResourceByUri (Private->RedfishService, Uri, &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", > __FUNCTION__, Uri)); > + return Status; > + } > + > + Private->Uri = Uri; > + Private->Payload = Response.Payload; > + ASSERT (Private->Payload != NULL); > + > + Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), > EDKII_JSON_COMPACT); > + ASSERT (Private->Json != NULL); > + > + // > + // Find etag in HTTP response header > + // > + Etag = NULL; > + Status = GetEtagAndLocation (&Response, &Etag, NULL); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", > __FUNCTION__)); > + } > + > + Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag); > + if (EFI_ERROR (Status)) { > + if (Status != EFI_ALREADY_STARTED) { > + DEBUG ((DEBUG_ERROR, "%a, failed to consume resource from: %s: > %r\n", __FUNCTION__, Uri, Status)); > + } > + } else { > + // > + // Keep etag after consuming pending settings. > + // > + if (Etag != NULL) { > + SetEtagWithUri (Etag, Private->Uri); > + } > + } > + > + // > + // Release resource > + // > + if (Private->Payload != NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + Private->Payload = NULL; > + } > + > + if (Private->Json != NULL) { > + FreePool (Private->Json); > + Private->Json = NULL; > + } > + > + return Status; > +} > + > +/** > + Get information about this protocol. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL > instance. > + @param[out] Schema Supported schema. > + @param[out] Major Supported major number. > + @param[out] Minor Supported minor number. > + @param[out] Errata Supported errata number. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishResourceGetInfo ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + OUT REDFISH_SCHEMA_INFO *Info > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + > + if (This == NULL || Info == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTO > COL (This); > + > + AsciiStrCpyS (Info->Schema, REDFISH_SCHEMA_STRING_SIZE, > RESOURCE_SCHEMA); > + AsciiStrCpyS (Info->Major, REDFISH_SCHEMA_VERSION_SIZE, > RESOURCE_SCHEMA_MAJOR); > + AsciiStrCpyS (Info->Minor, REDFISH_SCHEMA_VERSION_SIZE, > RESOURCE_SCHEMA_MINOR); > + AsciiStrCpyS (Info->Errata, REDFISH_SCHEMA_VERSION_SIZE, > RESOURCE_SCHEMA_ERRATA); > + > + return EFI_SUCCESS; > +} > + > +/** > + Update resource to given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL > instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishResourceUpdate ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if (This == NULL || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTO > COL (This); > + > + if (Private->RedfishService == NULL) { > + return EFI_NOT_READY; > + } > + > + Status = GetResourceByUri (Private->RedfishService, Uri, &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", > __FUNCTION__, Uri)); > + return Status; > + } > + > + Private->Uri = Uri; > + Private->Payload = Response.Payload; > + ASSERT (Private->Payload != NULL); > + > + Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), > EDKII_JSON_COMPACT); > + ASSERT (Private->Json != NULL); > + > + Status = RedfishUpdateResourceCommon (Private, Private->Json); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to update resource from: %s: %r\n", > __FUNCTION__, Uri, Status)); > + } > + > + // > + // Release resource > + // > + if (Private->Payload != NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + Private->Payload = NULL; > + } > + > + if (Private->Json != NULL) { > + FreePool (Private->Json); > + Private->Json = NULL; > + } > + > + return Status; > +} > + > +/** > + Check resource on given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL > instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishResourceCheck ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if (This == NULL || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTO > COL (This); > + > + if (Private->RedfishService == NULL) { > + return EFI_NOT_READY; > + } > + > + Status = GetResourceByUri (Private->RedfishService, Uri, &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", > __FUNCTION__, Uri)); > + return Status; > + } > + > + Private->Uri = Uri; > + Private->Payload = Response.Payload; > + ASSERT (Private->Payload != NULL); > + > + Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), > EDKII_JSON_COMPACT); > + ASSERT (Private->Json != NULL); > + > + Status = RedfishCheckResourceCommon (Private, Private->Json); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", > __FUNCTION__, Uri, Status)); > + } > + > + // > + // Release resource > + // > + if (Private->Payload != NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + Private->Payload = NULL; > + } > + > + if (Private->Json != NULL) { > + FreePool (Private->Json); > + Private->Json = NULL; > + } > + > + return Status; > +} > + > +/** > + Identify resource on given URI. > + > + @param[in] This Pointer to > EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS This is target resource which we want to > handle. > + @retval EFI_UNSUPPORTED This is not the target resource. > + @retval Others Some error happened. > + > +**/ > + > +EFI_STATUS > +RedfishResourceIdentify ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if (This == NULL || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTO > COL (This); > + > + if (Private->RedfishService == NULL) { > + return EFI_NOT_READY; > + } > + > + Status = GetResourceByUri (Private->RedfishService, Uri, &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", > __FUNCTION__, Uri)); > + return Status; > + } > + > + Private->Uri = Uri; > + Private->Payload = Response.Payload; > + ASSERT (Private->Payload != NULL); > + > + Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), > EDKII_JSON_COMPACT); > + ASSERT (Private->Json != NULL); > + > + Status = RedfishIdentifyResourceCommon (Private, Private->Json); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, identify %s failed: %r\n", __FUNCTION__, > Uri, Status)); > + } > + // > + // Release resource > + // > + if (Private->Payload != NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + Private->Payload = NULL; > + } > + > + if (Private->Json != NULL) { > + FreePool (Private->Json); > + Private->Json = NULL; > + } > + > + return Status; > +} > + > +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig > = { > + RedfishResourceProvisioningResource, > + RedfishResourceConsumeResource, > + RedfishResourceUpdate, > + RedfishResourceCheck, > + RedfishResourceIdentify, > + RedfishResourceGetInfo > +}; > + > +/** > + Initialize a Redfish configure handler. > + > + This function will be called by the Redfish config driver to initialize > each > Redfish configure > + handler. > + > + @param[in] This Pointer to > EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance. > + @param[in] RedfishConfigServiceInfo Redfish service informaion. > + > + @retval EFI_SUCCESS The handler has been initialized > successfully. > + @retval EFI_DEVICE_ERROR Failed to create or configure the > REST EX > protocol instance. > + @retval EFI_ALREADY_STARTED This handler has already been > initialized. > + @retval Other Error happens during the > initialization. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceInit ( > + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This, > + IN REDFISH_CONFIG_SERVICE_INFORMATION > *RedfishConfigServiceInfo > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCO > L (This); > + > + Private->RedfishService = RedfishCreateService > (RedfishConfigServiceInfo); > + if (Private->RedfishService == NULL) { > + return EFI_DEVICE_ERROR; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + Stop a Redfish configure handler. > + > + @param[in] This Pointer to > EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance. > + > + @retval EFI_SUCCESS This handler has been stoped successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceStop ( > + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + > + Private = > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCO > L (This); > + > + if (Private->Event != NULL) { > + gBS->CloseEvent (Private->Event); > + Private->Event = NULL; > + } > + > + if (Private->RedfishService != NULL) { > + RedfishCleanupService (Private->RedfishService); > + Private->RedfishService = NULL; > + } > + > + if (Private->Payload != NULL) { > + RedfishCleanupPayload (Private->Payload); > + Private->Payload = NULL; > + } > + > + return EFI_SUCCESS; > +} > + > +EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler = { > + RedfishResourceInit, > + RedfishResourceStop > +}; > + > +/** > + Callback function when gEfiRestJsonStructureProtocolGuid is installed. > + > + @param[in] Event Event whose notification function is being invoked. > + @param[in] Context Pointer to the notification function's context. > +**/ > +VOID > +EFIAPI > +EfiRestJasonStructureProtocolIsReady > + ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_STATUS Status; > + > + if (mRedfishResourcePrivate == NULL) { > + return; > + } > + > + if (mRedfishResourcePrivate->JsonStructProtocol != NULL) { > + return; > + } > + > + Status = gBS->LocateProtocol ( > + &gEfiRestJsonStructureProtocolGuid, > + NULL, > + (VOID **)&mRedfishResourcePrivate->JsonStructProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to locate > gEfiRestJsonStructureProtocolGuid: %r\n", __FUNCTION__, Status)); > + } > + > + gBS->CloseEvent (Event); > +} > + > +/** > + Unloads an image. > + > + @param ImageHandle Handle that identifies the image to be > unloaded. > + > + @retval EFI_SUCCESS The image has been unloaded. > + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image > handle. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceUnload ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; > + > + if (mRedfishResourcePrivate == NULL) { > + return EFI_NOT_READY; > + } > + > + ConfigHandler = NULL; > + > + // > + // Firstly, find ConfigHandler Protocol interface in this ImageHandle. > + // > + Status = gBS->OpenProtocol ( > + ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + (VOID **) &ConfigHandler, > + NULL, > + NULL, > + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL > + ); > + if (EFI_ERROR (Status) || ConfigHandler == NULL) { > + return Status; > + } > + > + ConfigHandler->Stop (ConfigHandler); > + > + // > + // Last, uninstall ConfigHandler Protocol and resource protocol. > + // > + Status = gBS->UninstallMultipleProtocolInterfaces ( > + ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + ConfigHandler, > + &gEdkIIRedfishResourceConfigProtocolGuid, > + &mRedfishResourcePrivate->RedfishResourceConfig, > + NULL > + ); > + > + FreePool (mRedfishResourcePrivate); > + mRedfishResourcePrivate = NULL; > + > + return Status; > +} > + > +/** > + The callback function provided by Redfish Feature driver. > + > + @param[in] This Pointer to > EDKII_REDFISH_FEATURE_PROTOCOL > instance. > + @param[in] FeatureAction The action Redfish feature driver should > take. > + @param[in] Uri The collection URI. > + @param[in] Context The context of Redfish feature driver. > + @param[in,out] InformationExchange The pointer to > RESOURCE_INFORMATION_EXCHANGE > + > + @retval EFI_SUCCESS Redfish feature driver callback is > executed > successfully. > + @retval Others Some errors happened. > + > + @retval EFI_SUCCESS Redfish feature driver callback is > executed > successfully. > + @retval Others Some errors happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishExternalResourceResourceFeatureCallback ( > + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, > + IN FEATURE_CALLBACK_ACTION FeatureAction, > + IN VOID *Context, > + IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange > + ) > +{ > + EFI_STATUS Status; > + REDFISH_SERVICE RedfishService; > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STRING ResourceUri; > + > + if (FeatureAction != CallbackActionStartOperation) { > + return EFI_UNSUPPORTED; > + } > + > + Private = (REDFISH_RESOURCE_COMMON_PRIVATE *)Context; > + > + RedfishService = Private->RedfishService; > + if (RedfishService == NULL) { > + return EFI_NOT_READY; > + } > + > + // > + // Save in private structure. > + // > + Private->InformationExchange = InformationExchange; > + > + // > + // Find Redfish version on BMC > + // > + Private->RedfishVersion = RedfishGetVersion (RedfishService); > + > + // > + // Create the full URI from Redfish service root. > + // > + ResourceUri = (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * > sizeof(CHAR16)); > + if (ResourceUri == NULL) { > + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", > __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion); > + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange- > >SendInformation.FullUri); > + > + // > + // Initialize collection path > + // > + Private->Uri = RedfishGetUri (ResourceUri); > + if (Private->Uri == NULL) { > + ASSERT (FALSE); > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status = HandleResource (Private, Private->Uri); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, process external resource: %a failed: > %r\n", __FUNCTION__, Private->Uri, Status)); > + } > + > + FreePool (Private->Uri); > + return Status; > +} > + > +/** > + Callback function when gEdkIIRedfishFeatureProtocolGuid is installed. > + > + @param[in] Event Event whose notification function is being invoked. > + @param[in] Context Pointer to the notification function's context. > +**/ > +VOID > +EFIAPI > +EdkIIRedfishFeatureProtocolIsReady > + ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol; > + > + if (mRedfishResourcePrivate == NULL) { > + return; > + } > + > + if (mRedfishResourcePrivate->FeatureProtocol != NULL) { > + return; > + } > + > + Status = gBS->LocateProtocol ( > + &gEdkIIRedfishFeatureProtocolGuid, > + NULL, > + (VOID **)&FeatureProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to locate > gEdkIIRedfishFeatureProtocolGuid: %r\n", __FUNCTION__, Status)); > + gBS->CloseEvent (Event); > + return; > + } > + > + Status = FeatureProtocol->Register ( > + FeatureProtocol, > + REDFISH_MANAGED_URI, > + RedfishExternalResourceResourceFeatureCallback, > + (VOID *)mRedfishResourcePrivate > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, failed to register %s: %r\n", > __FUNCTION__, REDFISH_MANAGED_URI, Status)); > + } > + > + mRedfishResourcePrivate->FeatureProtocol = FeatureProtocol; > + > + gBS->CloseEvent (Event); > +} > + > +/** > + 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 including > + both device drivers and bus drivers. It initialize the global variables and > + publish the driver binding protocol. > + > + @param[in] ImageHandle The firmware allocated handle for the UEFI > image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The operation completed successfully. > + @retval EFI_ACCESS_DENIED EFI_ISCSI_INITIATOR_NAME_PROTOCOL > was installed unexpectedly. > + @retval Others Other errors as indicated. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + VOID *Registration; > + > + if (mRedfishResourcePrivate != NULL) { > + return EFI_ALREADY_STARTED; > + } > + > + medfishResourceConfigProtocolHandle = ImageHandle; > + > + mRedfishResourcePrivate = AllocateZeroPool (sizeof > (REDFISH_RESOURCE_COMMON_PRIVATE)); > + CopyMem (&mRedfishResourcePrivate->ConfigHandler, > &mRedfishConfigHandler, sizeof > (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL)); > + CopyMem (&mRedfishResourcePrivate->RedfishResourceConfig, > &mRedfishResourceConfig, sizeof > (EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL)); > + > + // > + // Publish config handler protocol and resource protocol. > + // > + Status = gBS->InstallMultipleProtocolInterfaces ( > + &ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + &mRedfishResourcePrivate->ConfigHandler, > + &gEdkIIRedfishResourceConfigProtocolGuid, > + &mRedfishResourcePrivate->RedfishResourceConfig, > + NULL > + ); > + > + EfiCreateProtocolNotifyEvent ( > + &gEfiRestJsonStructureProtocolGuid, > + TPL_CALLBACK, > + EfiRestJasonStructureProtocolIsReady, > + NULL, > + &Registration > + ); > + > + EfiCreateProtocolNotifyEvent ( > + &gEdkIIRedfishFeatureProtocolGuid, > + TPL_CALLBACK, > + EdkIIRedfishFeatureProtocolIsReady, > + (VOID *)mRedfishResourcePrivate, > + &Registration > + ); > + > + return Status; > +} > diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > new file mode 100644 > index 0000000000..8c01a3b877 > --- /dev/null > +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > @@ -0,0 +1,52 @@ > +## @file > +# > +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development > LP<BR> > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = BiosDxe > + FILE_GUID = d6c99bb0-ca18-45aa-8be6-a60c3ba5ecd8 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT = RedfishResourceEntryPoint > + UNLOAD_IMAGE = RedfishResourceUnload > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + RedfishClientPkg/RedfishClientPkg.dec > + > +[Sources] > + ../Common/BiosCommon.h > + ../Common/BiosCommon.c > + BiosDxe.c > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + EdkIIRedfishResourceConfigLib > + RedfishLib > + RedfishFeatureUtilityLib > + RedfishVersionLib > + RedfishResourceIdentifyLib > + UefiLib > + UefiDriverEntryPoint > + > +[Protocols] > + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED > + gEfiRestJsonStructureProtocolGuid ## CONSUMED > + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED > + gEdkIIRedfishFeatureProtocolGuid ## CONSUMED > + > +[Pcd] > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize > + > +[Depex] > + TRUE > diff --git a/RedfishClientPkg/RedfishClient.fdf.inc > b/RedfishClientPkg/RedfishClient.fdf.inc > index 90240efbf7..fa4e53898b 100644 > --- a/RedfishClientPkg/RedfishClient.fdf.inc > +++ b/RedfishClientPkg/RedfishClient.fdf.inc > @@ -18,6 +18,7 @@ > INF > RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf > INF > RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystem > Dxe.inf > INF > RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSyste > mCollectionDxe.inf > + INF RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > > !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc > # > @@ -27,4 +28,5 @@ > INF > RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_ > Dxe.inf > INF > RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSys > tem_V1_5_0_Dxe.inf > INF > RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerS > ystemCollection_Dxe.inf > + INF > RedfishClientPkg/Converter/Bios/v1_0_9/RedfishBios_V1_0_9_Dxe.inf > !endif > diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc > b/RedfishClientPkg/RedfishClientComponents.dsc.inc > index 084796e4b5..e83f4bc9bf 100644 > --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc > +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc > @@ -27,6 +27,7 @@ > > RedfishResourceIdentifyLib|RedfishClientPkg/Library/RedfishResourceIdenti > fyLibComuterSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.in > f > } > > RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSyste > mCollectionDxe.inf > + RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > > !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc > > @@ -37,3 +38,4 @@ > > RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_ > Dxe.inf > > RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSys > tem_V1_5_0_Dxe.inf > > RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerS > ystemCollection_Dxe.inf > + RedfishClientPkg/Converter/Bios/v1_0_9/RedfishBios_V1_0_9_Dxe.inf > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index 05ad09ef5e..fe0c4b0885 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -15,12 +15,16 @@ > !endif > > # > - # Below two modules should be pulled in by build tool. > + # Below modules should be pulled in by build tool. > # > > MemoryV1_7_1Lib|RedfishClientPkg/ConverterLib/edk2library/Memory/v1 > _7_1/Lib.inf > > MemoryCollectionLib|RedfishClientPkg/ConverterLib/edk2library/MemoryC > ollection/Lib.inf > > ComputerSystemV1_5_0Lib|RedfishClientPkg/ConverterLib/edk2library/Co > mputerSystem/v1_5_0/Lib.inf > > ComputerSystemCollectionLib|RedfishClientPkg/ConverterLib/edk2library/C > omputerSystemCollection/Lib.inf > + > BiosV1_0_9Lib|RedfishClientPkg/ConverterLib/edk2library/Bios/v1_0_9/Lib.i > nf > + # > + # Above modules should be pulled in by build tool. > + # > > NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf > HttpLib|NetworkPkg/Library/DxeHttpLib/DxeHttpLib.inf > -- > 2.32.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91954): https://edk2.groups.io/g/devel/message/91954 Mute This Topic: https://groups.io/mt/92641659/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-