- Add latest BIOS schema version 1.2.0 - Follow early fix in Bios.V1_0_9.c and add fix to Bios.V1_2_0.c
Signed-off-by: Nickle Wang <nick...@nvidia.com> Cc: Abner Chang <abner.ch...@amd.com> Cc: Igor Kulchytskyy <ig...@ami.com> Cc: Nick Ramirez <nrami...@nvidia.com> --- .../src/Bios/Bios.V1_2_0/Bios.V1_2_0.c | 1341 +++++++++-------- .../Features/Bios/v1_2_0/Common/BiosCommon.c | 863 +++++++++++ .../Features/Bios/v1_2_0/Common/BiosCommon.h | 31 + .../Features/Bios/v1_2_0/Dxe/BiosDxe.c | 823 ++++++++++ .../Features/Bios/v1_2_0/Dxe/BiosDxe.inf | 55 + 5 files changed, 2443 insertions(+), 670 deletions(-) create mode 100644 RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.c create mode 100644 RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.h create mode 100644 RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.c create mode 100644 RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.inf diff --git a/RedfishClientPkg/ConverterLib/src/Bios/Bios.V1_2_0/Bios.V1_2_0.c b/RedfishClientPkg/ConverterLib/src/Bios/Bios.V1_2_0/Bios.V1_2_0.c index 9e13ce1bbb..2fd6db6bb3 100644 --- a/RedfishClientPkg/ConverterLib/src/Bios/Bios.V1_2_0/Bios.V1_2_0.c +++ b/RedfishClientPkg/ConverterLib/src/Bios/Bios.V1_2_0/Bios.V1_2_0.c @@ -1,670 +1,671 @@ -// -// Auto-generated file by Redfish Schema C Structure Generator. -// https://github.com/DMTF/Redfish-Schema-C-Struct-Generator. -// -// (C) Copyright 2019-2022 Hewlett Packard Enterprise Development LP<BR> -// -// Copyright Notice: -// Copyright 2019-2022 Distributed Management Task Force, Inc. All rights reserved. -// License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md -// - -#include"Redfish_Bios_v1_2_0_CS.h" -#include <stdlib.h> -#include <string.h> -#include <jansson.h> - -RedfishCS_bool SupportedRedfishResource (RedfishCS_char *Odata_Type, RedfishCS_char *NameSpace, RedfishCS_char *Version, RedfishCS_char *DataType); -RedfishCS_status CreateCsUriByNode (RedfishCS_void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_Uri_Data **CsTypeUriData); -RedfishCS_status CreateCsJsonByNode (RedfishCS_void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_JSON_Data **CsTypeJsonData); -RedfishCS_status CreateCsUriOrJsonByNode (RedfishCS_void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Link *LinkHead); -RedfishCS_status CreateCsUriOrJsonByNodeArray (RedfishCS_void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Link *LinkHead); -RedfishCS_status CreateJsonPayloadAndCs (char *JsonRawText, char *ResourceType, char *ResourceVersion, char *TypeName, json_t **JsonObjReturned, void **Cs, int size); -RedfishCS_status GetRedfishPropertyStr (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_char **DstBuffer); -RedfishCS_status GetRedfishPropertyBoolean (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_bool **DstBuffer); -RedfishCS_status GetRedfishPropertyVague (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_Vague **DstBuffer); -RedfishCS_status DestoryCsMemory (RedfishCS_void *rootCs); -RedfishCS_status GetRedfishPropertyInt64 (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_int64 **Dst); -RedfishCS_status InsertJsonStringObj (json_t *JsonObj, char *Key, char *StringValue); -RedfishCS_status InsertJsonLinkObj (json_t *JsonObj, char *Key, RedfishCS_Link *Link); -RedfishCS_status InsertJsonInt64Obj (json_t *ParentJsonObj, char *Key, RedfishCS_int64 *Int64Value); -RedfishCS_status InsertJsonBoolObj (json_t *ParentJsonObj, char *Key, RedfishCS_bool *BoolValue); -RedfishCS_status InsertJsonStringArrayObj (json_t *JsonObj, char *Key, RedfishCS_char_Array *StringValueArray); -RedfishCS_status InsertJsonLinkArrayObj (json_t *JsonObj, char *Key, RedfishCS_Link *LinkArray); -RedfishCS_status InsertJsonInt64ArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_int64_Array *Int64ValueArray); -RedfishCS_status InsertJsonBoolArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_bool_Array *BoolValueArray); -RedfishCS_status InsertJsonVagueObj (json_t *ParentJsonObj, char *Key, RedfishCS_Vague *VagueValue); -RedfishCS_bool CheckEmptyPropJsonObject(json_t *JsonObj, RedfishCS_uint32 *NumOfProperty); -RedfishCS_status CreateEmptyPropCsJson(RedfishCS_void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_EmptyProp_CS_Data **CsTypeEmptyPropCS, RedfishCS_uint32 NunmOfProperties); -RedfishCS_status CsEmptyPropLinkToJson(json_t *CsJson, char *Key, RedfishCS_Link *Link); - -static RedfishCS_status GenOemCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishResource_Oem_CS **Dst); -// -//Generate C structure for #Bios.ChangePassword -// -static RedfishCS_status GenChangePasswordCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_ChangePassword_CS **Dst) -{ - RedfishCS_status Status; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_ChangePassword_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - // target - Status = GetRedfishPropertyStr (Cs, TempJsonObj, "target", &(*Dst)->target); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // title - Status = GetRedfishPropertyStr (Cs, TempJsonObj, "title", &(*Dst)->title); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - -Error:; - return Status; -} -// -//Generate C structure for #Bios.ResetBios -// -static RedfishCS_status GenResetBiosCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_ResetBios_CS **Dst) -{ - RedfishCS_status Status; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_ResetBios_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - // target - Status = GetRedfishPropertyStr (Cs, TempJsonObj, "target", &(*Dst)->target); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // title - Status = GetRedfishPropertyStr (Cs, TempJsonObj, "title", &(*Dst)->title); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - -Error:; - return Status; -} -// -//Generate C structure for Oem -// -static RedfishCS_status GenOemActionsCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_OemActions_CS **Dst) -{ - RedfishCS_status Status; - RedfishCS_Type_JSON_Data *CsTypeJson; - RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS; - RedfishCS_uint32 NunmOfEmptyPropProperties; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_OemActions_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - InitializeLinkHead (&(*Dst)->Prop); - - // - // Try to create C structure if the property is - // declared as empty property in schema. The supported property type - // is string, integer, real, number and boolean. - // - if (CheckEmptyPropJsonObject(TempJsonObj, &NunmOfEmptyPropProperties)) { - Status = CreateEmptyPropCsJson(Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeEmptyPropCS, NunmOfEmptyPropProperties); - if (Status != RedfishCS_status_success) { - goto Error; - } - InsertTailLink(&(*Dst)->Prop, &CsTypeEmptyPropCS->Header.LinkEntry); - } else { - Status = CreateCsJsonByNode (Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeJson); - if (Status != RedfishCS_status_success) { - goto Error; - } - InsertTailLink(&(*Dst)->Prop, &CsTypeJson->Header.LinkEntry); - } -Error:; - return Status; -} -// -//Generate C structure for Actions -// -static RedfishCS_status GenActionsCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_Actions_CS **Dst) -{ - RedfishCS_status Status; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_Actions_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - // #Bios.ChangePassword - Status = GenChangePasswordCs (Cs, TempJsonObj, "#Bios.ChangePassword", &(*Dst)->Bios_ChangePassword); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // #Bios.ResetBios - Status = GenResetBiosCs (Cs, TempJsonObj, "#Bios.ResetBios", &(*Dst)->Bios_ResetBios); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // Oem - Status = GenOemActionsCs (Cs, TempJsonObj, "Oem", &(*Dst)->Oem); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - -Error:; - return Status; -} -// -//Generate C structure for Attributes -// -static RedfishCS_status GenAttributesCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_Attributes_CS **Dst) -{ - RedfishCS_status Status; - RedfishCS_Type_JSON_Data *CsTypeJson; - RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS; - RedfishCS_uint32 NunmOfEmptyPropProperties; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_Attributes_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - InitializeLinkHead (&(*Dst)->Prop); - - // - // Try to create C structure if the property is - // declared as empty property in schema. The supported property type - // is string, integer, real, number and boolean. - // - if (CheckEmptyPropJsonObject(TempJsonObj, &NunmOfEmptyPropProperties)) { - Status = CreateEmptyPropCsJson(Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeEmptyPropCS, NunmOfEmptyPropProperties); - if (Status != RedfishCS_status_success) { - goto Error; - } - InsertTailLink(&(*Dst)->Prop, &CsTypeEmptyPropCS->Header.LinkEntry); - } else { - Status = CreateCsJsonByNode (Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeJson); - if (Status != RedfishCS_status_success) { - goto Error; - } - InsertTailLink(&(*Dst)->Prop, &CsTypeJson->Header.LinkEntry); - } -Error:; - return Status; -} -// -//Generate C structure for Oem -// -static RedfishCS_status GenOemCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishResource_Oem_CS **Dst) -{ - RedfishCS_status Status; - RedfishCS_Type_JSON_Data *CsTypeJson; - RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS; - RedfishCS_uint32 NunmOfEmptyPropProperties; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishResource_Oem_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - InitializeLinkHead (&(*Dst)->Prop); - - // - // Try to create C structure if the property is - // declared as empty property in schema. The supported property type - // is string, integer, real, number and boolean. - // - if (CheckEmptyPropJsonObject(TempJsonObj, &NunmOfEmptyPropProperties)) { - Status = CreateEmptyPropCsJson(Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeEmptyPropCS, NunmOfEmptyPropProperties); - if (Status != RedfishCS_status_success) { - goto Error; - } - InsertTailLink(&(*Dst)->Prop, &CsTypeEmptyPropCS->Header.LinkEntry); - } else { - Status = CreateCsJsonByNode (Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeJson); - if (Status != RedfishCS_status_success) { - goto Error; - } - InsertTailLink(&(*Dst)->Prop, &CsTypeJson->Header.LinkEntry); - } -Error:; - return Status; -} -// -//Generate C structure for Links -// -static RedfishCS_status GenLinksCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_Links_CS **Dst) -{ - RedfishCS_status Status; - json_t *TempJsonObj; - - Status = RedfishCS_status_success; - TempJsonObj = json_object_get(JsonObj, Key); - if (TempJsonObj == NULL) { - return RedfishCS_status_not_found; - } - Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_Links_CS), (RedfishCS_void **)Dst); - if (Status != RedfishCS_status_success){ - goto Error; - } - // ActiveSoftwareImage - InitializeLinkHead (&(*Dst)->ActiveSoftwareImage); - Status = CreateCsUriOrJsonByNode (Cs, TempJsonObj, "ActiveSoftwareImage", Cs->Header.ThisUri, &(*Dst)->ActiveSoftwareImage); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // Oem - Status = GenOemCs (Cs, TempJsonObj, "Oem", &(*Dst)->Oem); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // SoftwareImages - InitializeLinkHead (&(*Dst)->SoftwareImages); - Status = CreateCsUriOrJsonByNodeArray (Cs, TempJsonObj, "SoftwareImages", Cs->Header.ThisUri, &(*Dst)->SoftwareImages); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // SoftwareImages@odata.count - Status = GetRedfishPropertyInt64 (Cs, TempJsonObj, "SoftwareImages@odata.count", &(*Dst)->SoftwareImagesodata_count); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - -Error:; - return Status; -} -static RedfishCS_status CS_To_JSON_ActionsBios_ChangePassword(json_t *CsJson, char *Key, RedfishBios_V1_2_0_ChangePassword_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // target - if (InsertJsonStringObj (CsJson, "target", CSPtr->target) != RedfishCS_status_success) {goto Error;} - - // title - if (InsertJsonStringObj (CsJson, "title", CSPtr->title) != RedfishCS_status_success) {goto Error;} - - // Set to parent JSON object. - if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} - - return RedfishCS_status_success; -Error:; - return RedfishCS_status_unsupported; -} -static RedfishCS_status CS_To_JSON_ActionsBios_ResetBios(json_t *CsJson, char *Key, RedfishBios_V1_2_0_ResetBios_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // target - if (InsertJsonStringObj (CsJson, "target", CSPtr->target) != RedfishCS_status_success) {goto Error;} - - // title - if (InsertJsonStringObj (CsJson, "title", CSPtr->title) != RedfishCS_status_success) {goto Error;} - - // Set to parent JSON object. - if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} - - return RedfishCS_status_success; -Error:; - return RedfishCS_status_unsupported; -} -static RedfishCS_status CS_To_JSON_ActionsOem(json_t *CsJson, char *Key, RedfishBios_V1_2_0_OemActions_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // Check if this is RedfishCS_Type_CS_EmptyProp. - CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); - // No JSON property for this structure. - return RedfishCS_status_success; -} -static RedfishCS_status CS_To_JSON_Actions(json_t *CsJson, char *Key, RedfishBios_V1_2_0_Actions_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // #Bios.ChangePassword - if (CS_To_JSON_ActionsBios_ChangePassword(CsJson, "#Bios.ChangePassword", CSPtr->Bios_ChangePassword) != RedfishCS_status_success) {goto Error;} - - // #Bios.ResetBios - if (CS_To_JSON_ActionsBios_ResetBios(CsJson, "#Bios.ResetBios", CSPtr->Bios_ResetBios) != RedfishCS_status_success) {goto Error;} - - // Oem - if (CS_To_JSON_ActionsOem(CsJson, "Oem", CSPtr->Oem) != RedfishCS_status_success) {goto Error;} - - // Set to parent JSON object. - if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} - - return RedfishCS_status_success; -Error:; - return RedfishCS_status_unsupported; -} -static RedfishCS_status CS_To_JSON_Attributes(json_t *CsJson, char *Key, RedfishBios_V1_2_0_Attributes_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // Check if this is RedfishCS_Type_CS_EmptyProp. - CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); - // No JSON property for this structure. - return RedfishCS_status_success; -} -static RedfishCS_status CS_To_JSON_LinksOem(json_t *CsJson, char *Key, RedfishResource_Oem_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // Check if this is RedfishCS_Type_CS_EmptyProp. - CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); - // No JSON property for this structure. - return RedfishCS_status_success; -} -static RedfishCS_status CS_To_JSON_Links(json_t *CsJson, char *Key, RedfishBios_V1_2_0_Links_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // ActiveSoftwareImage - if (InsertJsonLinkObj (CsJson, "ActiveSoftwareImage", &CSPtr->ActiveSoftwareImage) != RedfishCS_status_success) {goto Error;} - - // Oem - if (CS_To_JSON_LinksOem(CsJson, "Oem", CSPtr->Oem) != RedfishCS_status_success) {goto Error;} - - // SoftwareImages - if (InsertJsonLinkArrayObj (CsJson, "SoftwareImages", &CSPtr->SoftwareImages) != RedfishCS_status_success) {goto Error;} - - // SoftwareImages@odata.count - if (InsertJsonInt64Obj (CsJson, "SoftwareImages@odata.count", CSPtr->SoftwareImagesodata_count) != RedfishCS_status_success) {goto Error;} - - // Set to parent JSON object. - if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} - - return RedfishCS_status_success; -Error:; - return RedfishCS_status_unsupported; -} -static RedfishCS_status CS_To_JSON_Oem(json_t *CsJson, char *Key, RedfishResource_Oem_CS *CSPtr) -{ - json_t *CsParentJson; - - if (CSPtr == NULL) { - return RedfishCS_status_success; - } - - CsParentJson = CsJson; - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - - // Check if this is RedfishCS_Type_CS_EmptyProp. - CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); - // No JSON property for this structure. - return RedfishCS_status_success; -} - -// -// C structure to JSON for Bios.V1_2_0.Bios -// -RedfishCS_status CS_To_Bios_V1_2_0_JSON(RedfishBios_V1_2_0_Bios_CS *CSPtr, RedfishCS_char **JsonText) -{ - json_t *CsJson; - - if (CSPtr == NULL || JsonText == NULL || CSPtr->Header.ResourceType != RedfishCS_Type_CS) { - return RedfishCS_status_invalid_parameter; - } - CsJson = json_object(); - if (CsJson == NULL) { - return RedfishCS_status_unsupported; - } - // Actions - if (CS_To_JSON_Actions(CsJson, "Actions", CSPtr->Actions) != RedfishCS_status_success) {goto Error;} - - // AttributeRegistry - if (InsertJsonStringObj (CsJson, "AttributeRegistry", CSPtr->AttributeRegistry) != RedfishCS_status_success) {goto Error;} - - // Attributes - if (CS_To_JSON_Attributes(CsJson, "Attributes", CSPtr->Attributes) != RedfishCS_status_success) {goto Error;} - - // Description - if (InsertJsonStringObj (CsJson, "Description", CSPtr->Description) != RedfishCS_status_success) {goto Error;} - - // Id - if (InsertJsonStringObj (CsJson, "Id", CSPtr->Id) != RedfishCS_status_success) {goto Error;} - - // Links - if (CS_To_JSON_Links(CsJson, "Links", CSPtr->Links) != RedfishCS_status_success) {goto Error;} - - // Name - if (InsertJsonStringObj (CsJson, "Name", CSPtr->Name) != RedfishCS_status_success) {goto Error;} - - // Oem - if (CS_To_JSON_Oem(CsJson, "Oem", CSPtr->Oem) != RedfishCS_status_success) {goto Error;} - - // ResetBiosToDefaultsPending - if (InsertJsonBoolObj (CsJson, "ResetBiosToDefaultsPending", CSPtr->ResetBiosToDefaultsPending) != RedfishCS_status_success) {goto Error;} - - // @odata.context - if (InsertJsonStringObj (CsJson, "@odata.context", CSPtr->odata_context) != RedfishCS_status_success) {goto Error;} - - // @odata.etag - if (InsertJsonStringObj (CsJson, "@odata.etag", CSPtr->odata_etag) != RedfishCS_status_success) {goto Error;} - - // @odata.id - if (InsertJsonStringObj (CsJson, "@odata.id", CSPtr->odata_id) != RedfishCS_status_success) {goto Error;} - - // @odata.type - if (InsertJsonStringObj (CsJson, "@odata.type", CSPtr->odata_type) != RedfishCS_status_success) {goto Error;} - - *JsonText = (RedfishCS_char *)json_dumps(CsJson, JSON_INDENT(2 * 1) | JSON_ENSURE_ASCII); - json_decref(CsJson); - return RedfishCS_status_success; -Error:; - json_decref(CsJson); - return RedfishCS_status_unsupported; -} - -// -// Destory C Structure for Bios.V1_2_0.Bios -// -RedfishCS_status DestroyBios_V1_2_0_CS(RedfishBios_V1_2_0_Bios_CS *CSPtr) -{ - RedfishCS_status Status; - - Status = DestoryCsMemory ((RedfishCS_void *)CSPtr); - return Status; -} - -// -// Destory JSON text for Bios.V1_2_0.Bios -// -RedfishCS_status DestroyBios_V1_2_0_Json(RedfishCS_char *JsonText) -{ - free ((RedfishCS_void *)JsonText); - return RedfishCS_status_success; -} - -// -//Generate C structure for Bios.V1_2_0.Bios -// -RedfishCS_status -Json_Bios_V1_2_0_To_CS(RedfishCS_char *JsonRawText, RedfishBios_V1_2_0_Bios_CS **ReturnedCs) -{ - RedfishCS_status Status; - json_t *JsonObj; - RedfishBios_V1_2_0_Bios_CS *Cs; - - Status = CreateJsonPayloadAndCs (JsonRawText, "Bios", "v1_2_0", "Bios", &JsonObj, (RedfishCS_void **)&Cs, sizeof (RedfishBios_V1_2_0_Bios_CS)); - if (Status != RedfishCS_status_success) { - goto Error; - } - - // @odata.context - Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.context", &Cs->odata_context); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // @odata.etag - Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.etag", &Cs->odata_etag); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // @odata.id - Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.id", &Cs->odata_id); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){goto Error;}} - - // @odata.type - Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.type", &Cs->odata_type); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){goto Error;}} - - // Actions - Status = GenActionsCs (Cs, JsonObj, "Actions", &Cs->Actions); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // AttributeRegistry - Status = GetRedfishPropertyStr (Cs, JsonObj, "AttributeRegistry", &Cs->AttributeRegistry); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // Attributes - Status = GenAttributesCs (Cs, JsonObj, "Attributes", &Cs->Attributes); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // Description - Status = GetRedfishPropertyStr (Cs, JsonObj, "Description", &Cs->Description); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // Id - Status = GetRedfishPropertyStr (Cs, JsonObj, "Id", &Cs->Id); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){goto Error;}} - - // Links - Status = GenLinksCs (Cs, JsonObj, "Links", &Cs->Links); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // Name - Status = GetRedfishPropertyStr (Cs, JsonObj, "Name", &Cs->Name); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){goto Error;}} - - // Oem - Status = GenOemCs (Cs, JsonObj, "Oem", &Cs->Oem); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - // ResetBiosToDefaultsPending - Status = GetRedfishPropertyBoolean (Cs, JsonObj, "ResetBiosToDefaultsPending", &Cs->ResetBiosToDefaultsPending); - if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} - else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} - - json_decref(JsonObj); - *ReturnedCs = Cs; - return RedfishCS_status_success; -Error:; - json_decref(JsonObj); - DestroyBios_V1_2_0_CS (Cs); - return Status; -} +// +// Auto-generated file by Redfish Schema C Structure Generator. +// https://github.com/DMTF/Redfish-Schema-C-Struct-Generator. +// +// (C) Copyright 2019-2022 Hewlett Packard Enterprise Development LP<BR> +// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +// Copyright Notice: +// Copyright 2019-2022 Distributed Management Task Force, Inc. All rights reserved. +// License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md +// + +#include"Redfish_Bios_v1_2_0_CS.h" +#include <stdlib.h> +#include <string.h> +#include <jansson.h> + +RedfishCS_bool SupportedRedfishResource (RedfishCS_char *Odata_Type, RedfishCS_char *NameSpace, RedfishCS_char *Version, RedfishCS_char *DataType); +RedfishCS_status CreateCsUriByNode (RedfishCS_void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_Uri_Data **CsTypeUriData); +RedfishCS_status CreateCsJsonByNode (RedfishCS_void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_JSON_Data **CsTypeJsonData); +RedfishCS_status CreateCsUriOrJsonByNode (RedfishCS_void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Link *LinkHead); +RedfishCS_status CreateCsUriOrJsonByNodeArray (RedfishCS_void *Cs, json_t *JsonObj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Link *LinkHead); +RedfishCS_status CreateJsonPayloadAndCs (char *JsonRawText, char *ResourceType, char *ResourceVersion, char *TypeName, json_t **JsonObjReturned, void **Cs, int size); +RedfishCS_status GetRedfishPropertyStr (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_char **DstBuffer); +RedfishCS_status GetRedfishPropertyBoolean (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_bool **DstBuffer); +RedfishCS_status GetRedfishPropertyVague (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_Vague **DstBuffer); +RedfishCS_status DestoryCsMemory (RedfishCS_void *rootCs); +RedfishCS_status GetRedfishPropertyInt64 (RedfishCS_void *Cs, json_t *JsonObj, char *Key, RedfishCS_int64 **Dst); +RedfishCS_status InsertJsonStringObj (json_t *JsonObj, char *Key, char *StringValue); +RedfishCS_status InsertJsonLinkObj (json_t *JsonObj, char *Key, RedfishCS_Link *Link); +RedfishCS_status InsertJsonInt64Obj (json_t *ParentJsonObj, char *Key, RedfishCS_int64 *Int64Value); +RedfishCS_status InsertJsonBoolObj (json_t *ParentJsonObj, char *Key, RedfishCS_bool *BoolValue); +RedfishCS_status InsertJsonStringArrayObj (json_t *JsonObj, char *Key, RedfishCS_char_Array *StringValueArray); +RedfishCS_status InsertJsonLinkArrayObj (json_t *JsonObj, char *Key, RedfishCS_Link *LinkArray); +RedfishCS_status InsertJsonInt64ArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_int64_Array *Int64ValueArray); +RedfishCS_status InsertJsonBoolArrayObj (json_t *ParentJsonObj, char *Key, RedfishCS_bool_Array *BoolValueArray); +RedfishCS_status InsertJsonVagueObj (json_t *ParentJsonObj, char *Key, RedfishCS_Vague *VagueValue); +RedfishCS_bool CheckEmptyPropJsonObject(json_t *JsonObj, RedfishCS_uint32 *NumOfProperty); +RedfishCS_status CreateEmptyPropCsJson(RedfishCS_void *Cs, json_t *JsonOj, RedfishCS_char *NodeName, RedfishCS_char *ParentUri, RedfishCS_Type_EmptyProp_CS_Data **CsTypeEmptyPropCS, RedfishCS_uint32 NunmOfProperties); +RedfishCS_status CsEmptyPropLinkToJson(json_t *CsJson, char *Key, RedfishCS_Link *Link); + +static RedfishCS_status GenOemCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishResource_Oem_CS **Dst); +// +//Generate C structure for #Bios.ChangePassword +// +static RedfishCS_status GenChangePasswordCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_ChangePassword_CS **Dst) +{ + RedfishCS_status Status; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_ChangePassword_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + // target + Status = GetRedfishPropertyStr (Cs, TempJsonObj, "target", &(*Dst)->target); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // title + Status = GetRedfishPropertyStr (Cs, TempJsonObj, "title", &(*Dst)->title); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + +Error:; + return Status; +} +// +//Generate C structure for #Bios.ResetBios +// +static RedfishCS_status GenResetBiosCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_ResetBios_CS **Dst) +{ + RedfishCS_status Status; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_ResetBios_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + // target + Status = GetRedfishPropertyStr (Cs, TempJsonObj, "target", &(*Dst)->target); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // title + Status = GetRedfishPropertyStr (Cs, TempJsonObj, "title", &(*Dst)->title); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + +Error:; + return Status; +} +// +//Generate C structure for Oem +// +static RedfishCS_status GenOemActionsCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_OemActions_CS **Dst) +{ + RedfishCS_status Status; + RedfishCS_Type_JSON_Data *CsTypeJson; + RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS; + RedfishCS_uint32 NunmOfEmptyPropProperties; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_OemActions_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + InitializeLinkHead (&(*Dst)->Prop); + + // + // Try to create C structure if the property is + // declared as empty property in schema. The supported property type + // is string, integer, real, number and boolean. + // + if (CheckEmptyPropJsonObject(TempJsonObj, &NunmOfEmptyPropProperties)) { + Status = CreateEmptyPropCsJson(Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeEmptyPropCS, NunmOfEmptyPropProperties); + if (Status != RedfishCS_status_success) { + goto Error; + } + InsertTailLink(&(*Dst)->Prop, &CsTypeEmptyPropCS->Header.LinkEntry); + } else { + Status = CreateCsJsonByNode (Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeJson); + if (Status != RedfishCS_status_success) { + goto Error; + } + InsertTailLink(&(*Dst)->Prop, &CsTypeJson->Header.LinkEntry); + } +Error:; + return Status; +} +// +//Generate C structure for Actions +// +static RedfishCS_status GenActionsCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_Actions_CS **Dst) +{ + RedfishCS_status Status; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_Actions_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + // #Bios.ChangePassword + Status = GenChangePasswordCs (Cs, TempJsonObj, "#Bios.ChangePassword", &(*Dst)->Bios_ChangePassword); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // #Bios.ResetBios + Status = GenResetBiosCs (Cs, TempJsonObj, "#Bios.ResetBios", &(*Dst)->Bios_ResetBios); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // Oem + Status = GenOemActionsCs (Cs, TempJsonObj, "Oem", &(*Dst)->Oem); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + +Error:; + return Status; +} +// +//Generate C structure for Attributes +// +static RedfishCS_status GenAttributesCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_Attributes_CS **Dst) +{ + RedfishCS_status Status; + RedfishCS_Type_JSON_Data *CsTypeJson; + RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS; + RedfishCS_uint32 NunmOfEmptyPropProperties; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_Attributes_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + InitializeLinkHead (&(*Dst)->Prop); + + // + // Try to create C structure if the property is + // declared as empty property in schema. The supported property type + // is string, integer, real, number and boolean. + // + if (CheckEmptyPropJsonObject(TempJsonObj, &NunmOfEmptyPropProperties)) { + Status = CreateEmptyPropCsJson(Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeEmptyPropCS, NunmOfEmptyPropProperties); + if (Status != RedfishCS_status_success) { + goto Error; + } + InsertTailLink(&(*Dst)->Prop, &CsTypeEmptyPropCS->Header.LinkEntry); + } else { + Status = CreateCsJsonByNode (Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeJson); + if (Status != RedfishCS_status_success) { + goto Error; + } + InsertTailLink(&(*Dst)->Prop, &CsTypeJson->Header.LinkEntry); + } +Error:; + return Status; +} +// +//Generate C structure for Oem +// +static RedfishCS_status GenOemCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishResource_Oem_CS **Dst) +{ + RedfishCS_status Status; + RedfishCS_Type_JSON_Data *CsTypeJson; + RedfishCS_Type_EmptyProp_CS_Data *CsTypeEmptyPropCS; + RedfishCS_uint32 NunmOfEmptyPropProperties; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishResource_Oem_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + InitializeLinkHead (&(*Dst)->Prop); + + // + // Try to create C structure if the property is + // declared as empty property in schema. The supported property type + // is string, integer, real, number and boolean. + // + if (CheckEmptyPropJsonObject(TempJsonObj, &NunmOfEmptyPropProperties)) { + Status = CreateEmptyPropCsJson(Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeEmptyPropCS, NunmOfEmptyPropProperties); + if (Status != RedfishCS_status_success) { + goto Error; + } + InsertTailLink(&(*Dst)->Prop, &CsTypeEmptyPropCS->Header.LinkEntry); + } else { + Status = CreateCsJsonByNode (Cs, JsonObj, Key, Cs->Header.ThisUri, &CsTypeJson); + if (Status != RedfishCS_status_success) { + goto Error; + } + InsertTailLink(&(*Dst)->Prop, &CsTypeJson->Header.LinkEntry); + } +Error:; + return Status; +} +// +//Generate C structure for Links +// +static RedfishCS_status GenLinksCs(RedfishBios_V1_2_0_Bios_CS *Cs, json_t *JsonObj, char *Key, RedfishBios_V1_2_0_Links_CS **Dst) +{ + RedfishCS_status Status; + json_t *TempJsonObj; + + Status = RedfishCS_status_success; + TempJsonObj = json_object_get(JsonObj, Key); + if (TempJsonObj == NULL) { + return RedfishCS_status_not_found; + } + Status = allocateRecordCsMemory(Cs, sizeof(RedfishBios_V1_2_0_Links_CS), (RedfishCS_void **)Dst); + if (Status != RedfishCS_status_success){ + goto Error; + } + // ActiveSoftwareImage + InitializeLinkHead (&(*Dst)->ActiveSoftwareImage); + Status = CreateCsUriOrJsonByNode (Cs, TempJsonObj, "ActiveSoftwareImage", Cs->Header.ThisUri, &(*Dst)->ActiveSoftwareImage); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // Oem + Status = GenOemCs (Cs, TempJsonObj, "Oem", &(*Dst)->Oem); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // SoftwareImages + InitializeLinkHead (&(*Dst)->SoftwareImages); + Status = CreateCsUriOrJsonByNodeArray (Cs, TempJsonObj, "SoftwareImages", Cs->Header.ThisUri, &(*Dst)->SoftwareImages); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // SoftwareImages@odata.count + Status = GetRedfishPropertyInt64 (Cs, TempJsonObj, "SoftwareImages@odata.count", &(*Dst)->SoftwareImagesodata_count); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + +Error:; + return Status; +} +static RedfishCS_status CS_To_JSON_ActionsBios_ChangePassword(json_t *CsJson, char *Key, RedfishBios_V1_2_0_ChangePassword_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // target + if (InsertJsonStringObj (CsJson, "target", CSPtr->target) != RedfishCS_status_success) {goto Error;} + + // title + if (InsertJsonStringObj (CsJson, "title", CSPtr->title) != RedfishCS_status_success) {goto Error;} + + // Set to parent JSON object. + if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} + + return RedfishCS_status_success; +Error:; + return RedfishCS_status_unsupported; +} +static RedfishCS_status CS_To_JSON_ActionsBios_ResetBios(json_t *CsJson, char *Key, RedfishBios_V1_2_0_ResetBios_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // target + if (InsertJsonStringObj (CsJson, "target", CSPtr->target) != RedfishCS_status_success) {goto Error;} + + // title + if (InsertJsonStringObj (CsJson, "title", CSPtr->title) != RedfishCS_status_success) {goto Error;} + + // Set to parent JSON object. + if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} + + return RedfishCS_status_success; +Error:; + return RedfishCS_status_unsupported; +} +static RedfishCS_status CS_To_JSON_ActionsOem(json_t *CsJson, char *Key, RedfishBios_V1_2_0_OemActions_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // Check if this is RedfishCS_Type_CS_EmptyProp. + CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); + // No JSON property for this structure. + return RedfishCS_status_success; +} +static RedfishCS_status CS_To_JSON_Actions(json_t *CsJson, char *Key, RedfishBios_V1_2_0_Actions_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // #Bios.ChangePassword + if (CS_To_JSON_ActionsBios_ChangePassword(CsJson, "#Bios.ChangePassword", CSPtr->Bios_ChangePassword) != RedfishCS_status_success) {goto Error;} + + // #Bios.ResetBios + if (CS_To_JSON_ActionsBios_ResetBios(CsJson, "#Bios.ResetBios", CSPtr->Bios_ResetBios) != RedfishCS_status_success) {goto Error;} + + // Oem + if (CS_To_JSON_ActionsOem(CsJson, "Oem", CSPtr->Oem) != RedfishCS_status_success) {goto Error;} + + // Set to parent JSON object. + if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} + + return RedfishCS_status_success; +Error:; + return RedfishCS_status_unsupported; +} +static RedfishCS_status CS_To_JSON_Attributes(json_t *CsJson, char *Key, RedfishBios_V1_2_0_Attributes_CS *CSPtr) +{ + //json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + //CsParentJson = CsJson; + //CsJson = json_object(); + //if (CsJson == NULL) { + // return RedfishCS_status_unsupported; + //} + + // Check if this is RedfishCS_Type_CS_EmptyProp. + CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); + // No JSON property for this structure. + return RedfishCS_status_success; +} +static RedfishCS_status CS_To_JSON_LinksOem(json_t *CsJson, char *Key, RedfishResource_Oem_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // Check if this is RedfishCS_Type_CS_EmptyProp. + CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); + // No JSON property for this structure. + return RedfishCS_status_success; +} +static RedfishCS_status CS_To_JSON_Links(json_t *CsJson, char *Key, RedfishBios_V1_2_0_Links_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // ActiveSoftwareImage + if (InsertJsonLinkObj (CsJson, "ActiveSoftwareImage", &CSPtr->ActiveSoftwareImage) != RedfishCS_status_success) {goto Error;} + + // Oem + if (CS_To_JSON_LinksOem(CsJson, "Oem", CSPtr->Oem) != RedfishCS_status_success) {goto Error;} + + // SoftwareImages + if (InsertJsonLinkArrayObj (CsJson, "SoftwareImages", &CSPtr->SoftwareImages) != RedfishCS_status_success) {goto Error;} + + // SoftwareImages@odata.count + if (InsertJsonInt64Obj (CsJson, "SoftwareImages@odata.count", CSPtr->SoftwareImagesodata_count) != RedfishCS_status_success) {goto Error;} + + // Set to parent JSON object. + if (json_object_set_new (CsParentJson, Key, CsJson) == -1) {goto Error;} + + return RedfishCS_status_success; +Error:; + return RedfishCS_status_unsupported; +} +static RedfishCS_status CS_To_JSON_Oem(json_t *CsJson, char *Key, RedfishResource_Oem_CS *CSPtr) +{ + json_t *CsParentJson; + + if (CSPtr == NULL) { + return RedfishCS_status_success; + } + + CsParentJson = CsJson; + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + + // Check if this is RedfishCS_Type_CS_EmptyProp. + CsEmptyPropLinkToJson(CsJson, Key, &CSPtr->Prop); + // No JSON property for this structure. + return RedfishCS_status_success; +} + +// +// C structure to JSON for Bios.V1_2_0.Bios +// +RedfishCS_status CS_To_Bios_V1_2_0_JSON(RedfishBios_V1_2_0_Bios_CS *CSPtr, RedfishCS_char **JsonText) +{ + json_t *CsJson; + + if (CSPtr == NULL || JsonText == NULL || CSPtr->Header.ResourceType != RedfishCS_Type_CS) { + return RedfishCS_status_invalid_parameter; + } + CsJson = json_object(); + if (CsJson == NULL) { + return RedfishCS_status_unsupported; + } + // Actions + if (CS_To_JSON_Actions(CsJson, "Actions", CSPtr->Actions) != RedfishCS_status_success) {goto Error;} + + // AttributeRegistry + if (InsertJsonStringObj (CsJson, "AttributeRegistry", CSPtr->AttributeRegistry) != RedfishCS_status_success) {goto Error;} + + // Attributes + if (CS_To_JSON_Attributes(CsJson, "Attributes", CSPtr->Attributes) != RedfishCS_status_success) {goto Error;} + + // Description + if (InsertJsonStringObj (CsJson, "Description", CSPtr->Description) != RedfishCS_status_success) {goto Error;} + + // Id + if (InsertJsonStringObj (CsJson, "Id", CSPtr->Id) != RedfishCS_status_success) {goto Error;} + + // Links + if (CS_To_JSON_Links(CsJson, "Links", CSPtr->Links) != RedfishCS_status_success) {goto Error;} + + // Name + if (InsertJsonStringObj (CsJson, "Name", CSPtr->Name) != RedfishCS_status_success) {goto Error;} + + // Oem + if (CS_To_JSON_Oem(CsJson, "Oem", CSPtr->Oem) != RedfishCS_status_success) {goto Error;} + + // ResetBiosToDefaultsPending + if (InsertJsonBoolObj (CsJson, "ResetBiosToDefaultsPending", CSPtr->ResetBiosToDefaultsPending) != RedfishCS_status_success) {goto Error;} + + // @odata.context + if (InsertJsonStringObj (CsJson, "@odata.context", CSPtr->odata_context) != RedfishCS_status_success) {goto Error;} + + // @odata.etag + if (InsertJsonStringObj (CsJson, "@odata.etag", CSPtr->odata_etag) != RedfishCS_status_success) {goto Error;} + + // @odata.id + if (InsertJsonStringObj (CsJson, "@odata.id", CSPtr->odata_id) != RedfishCS_status_success) {goto Error;} + + // @odata.type + if (InsertJsonStringObj (CsJson, "@odata.type", CSPtr->odata_type) != RedfishCS_status_success) {goto Error;} + + *JsonText = (RedfishCS_char *)json_dumps(CsJson, JSON_INDENT(2 * 1) | JSON_ENSURE_ASCII); + json_decref(CsJson); + return RedfishCS_status_success; +Error:; + json_decref(CsJson); + return RedfishCS_status_unsupported; +} + +// +// Destory C Structure for Bios.V1_2_0.Bios +// +RedfishCS_status DestroyBios_V1_2_0_CS(RedfishBios_V1_2_0_Bios_CS *CSPtr) +{ + RedfishCS_status Status; + + Status = DestoryCsMemory ((RedfishCS_void *)CSPtr); + return Status; +} + +// +// Destory JSON text for Bios.V1_2_0.Bios +// +RedfishCS_status DestroyBios_V1_2_0_Json(RedfishCS_char *JsonText) +{ + free ((RedfishCS_void *)JsonText); + return RedfishCS_status_success; +} + +// +//Generate C structure for Bios.V1_2_0.Bios +// +RedfishCS_status +Json_Bios_V1_2_0_To_CS(RedfishCS_char *JsonRawText, RedfishBios_V1_2_0_Bios_CS **ReturnedCs) +{ + RedfishCS_status Status; + json_t *JsonObj; + RedfishBios_V1_2_0_Bios_CS *Cs; + + Status = CreateJsonPayloadAndCs (JsonRawText, "Bios", "v1_2_0", "Bios", &JsonObj, (RedfishCS_void **)&Cs, sizeof (RedfishBios_V1_2_0_Bios_CS)); + if (Status != RedfishCS_status_success) { + goto Error; + } + + // @odata.context + Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.context", &Cs->odata_context); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // @odata.etag + Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.etag", &Cs->odata_etag); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // @odata.id + Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.id", &Cs->odata_id); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){goto Error;}} + + // @odata.type + Status = GetRedfishPropertyStr (Cs, JsonObj, "@odata.type", &Cs->odata_type); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){goto Error;}} + + // Actions + Status = GenActionsCs (Cs, JsonObj, "Actions", &Cs->Actions); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // AttributeRegistry + Status = GetRedfishPropertyStr (Cs, JsonObj, "AttributeRegistry", &Cs->AttributeRegistry); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // Attributes + Status = GenAttributesCs (Cs, JsonObj, "Attributes", &Cs->Attributes); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // Description + Status = GetRedfishPropertyStr (Cs, JsonObj, "Description", &Cs->Description); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // Id + Status = GetRedfishPropertyStr (Cs, JsonObj, "Id", &Cs->Id); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){goto Error;}} + + // Links + Status = GenLinksCs (Cs, JsonObj, "Links", &Cs->Links); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // Name + Status = GetRedfishPropertyStr (Cs, JsonObj, "Name", &Cs->Name); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){goto Error;}} + + // Oem + Status = GenOemCs (Cs, JsonObj, "Oem", &Cs->Oem); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + // ResetBiosToDefaultsPending + Status = GetRedfishPropertyBoolean (Cs, JsonObj, "ResetBiosToDefaultsPending", &Cs->ResetBiosToDefaultsPending); + if (Status != RedfishCS_status_success && Status != RedfishCS_status_not_found) {goto Error;} + else {if (Status == RedfishCS_status_not_found){/*This is not the required property.*/}} + + json_decref(JsonObj); + *ReturnedCs = Cs; + return RedfishCS_status_success; +Error:; + json_decref(JsonObj); + DestroyBios_V1_2_0_CS (Cs); + return Status; +} diff --git a/RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.c b/RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.c new file mode 100644 index 0000000000..0673d54580 --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.c @@ -0,0 +1,863 @@ +/** @file + Redfish feature driver implementation - common functions + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "BiosCommon.h" + +CHAR8 BiosEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\": \"#Bios.v1_2_0.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_2_0 *Bios; + EFI_REDFISH_BIOS_V1_2_0_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 ((REDFISH_DEBUG_TRACE, "%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_2_0_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_2_0 *Bios; + EFI_REDFISH_BIOS_V1_2_0_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 + )) + { + DEBUG ((DEBUG_ERROR, "%a: PropertyVagueValues: %p VagueValueNumber: %d\n", __FUNCTION__, 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; + CHAR8 *JsonWithAddendum; + 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; + } + + // + // Check and see if platform has OEM data or not + // + Status = RedfishGetOemData ( + Private->Uri, + RESOURCE_SCHEMA, + RESOURCE_SCHEMA_VERSION, + Json, + &JsonWithAddendum + ); + if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) { + FreePool (Json); + Json = JsonWithAddendum; + JsonWithAddendum = NULL; + } + + // + // Check and see if platform has addendum data or not + // + Status = RedfishGetAddendumData ( + Private->Uri, + RESOURCE_SCHEMA, + RESOURCE_SCHEMA_VERSION, + Json, + &JsonWithAddendum + ); + if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) { + FreePool (Json); + Json = JsonWithAddendum; + JsonWithAddendum = NULL; + } + + 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 ((REDFISH_DEBUG_TRACE, "[%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; + CHAR8 *JsonWithAddendum; + + 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; + } + + // + // Check and see if platform has OEM data or not + // + Status = RedfishGetOemData ( + Private->Uri, + RESOURCE_SCHEMA, + RESOURCE_SCHEMA_VERSION, + Json, + &JsonWithAddendum + ); + if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) { + FreePool (Json); + Json = JsonWithAddendum; + JsonWithAddendum = NULL; + } + + // + // Check and see if platform has addendum data or not + // + Status = RedfishGetAddendumData ( + Private->Uri, + RESOURCE_SCHEMA, + RESOURCE_SCHEMA_VERSION, + Json, + &JsonWithAddendum + ); + if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) { + FreePool (Json); + Json = JsonWithAddendum; + JsonWithAddendum = NULL; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a: provisioning existing resource for %s\n", __FUNCTION__, ConfigureLang)); + + // + // PUT back to instance + // + Status = CreatePayloadToPutResource (Private->RedfishService, Private->Payload, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: put 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_UNSUPPORTED; + } + + Status = EFI_NOT_FOUND; + for (Index = 0; Index < Count; Index++) { + Property = GetPropertyFromConfigureLang (Private->Uri, ConfigureLangList[Index]); + if (Property == NULL) { + continue; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a: [%d] check attribute for: %s\n", __FUNCTION__, Index, Property)); + if (!MatchPropertyWithJsonContext (Property, Json)) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a: property is missing: %s\n", __FUNCTION__, Property)); + } else { + // + // When there is any attribute found in /Bios/Attributes, it means that + // the provisioning was performed before. Any missing attribute will + // be handled by update operation. + // When all attributes are missing in /Bios/Attributes, provisioning is + // performed. + // + Status = EFI_SUCCESS; + } + } + + 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; + CHAR8 *JsonWithAddendum; + 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, + BiosEmptyJson, + NULL, + ConfigureLang, + TRUE, + &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; + } + + // + // Check and see if platform has OEM data or not + // + Status = RedfishGetOemData ( + Private->Uri, + RESOURCE_SCHEMA, + RESOURCE_SCHEMA_VERSION, + Json, + &JsonWithAddendum + ); + if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) { + FreePool (Json); + Json = JsonWithAddendum; + JsonWithAddendum = NULL; + } + + // + // Check and see if platform has addendum data or not + // + Status = RedfishGetAddendumData ( + Private->Uri, + RESOURCE_SCHEMA, + RESOURCE_SCHEMA_VERSION, + Json, + &JsonWithAddendum + ); + if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) { + FreePool (Json); + Json = JsonWithAddendum; + JsonWithAddendum = NULL; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __FUNCTION__, ConfigureLang)); + // + // PUT back to instance + // + Status = CreatePayloadToPutResource (Private->RedfishService, Private->Payload, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: put 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 ((REDFISH_DEBUG_TRACE, "%a: \"%s\" is not handled by us\n", __FUNCTION__, Uri)); + return EFI_SUCCESS; + } else if (Status == EFI_NOT_FOUND) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a: \"%s\" has nothing to handle\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)) { + if (Status == EFI_UNSUPPORTED) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a: \"%s\" is not handled by us\n", __FUNCTION__, Uri)); + return EFI_SUCCESS; + } + + // + // 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_2_0/Common/BiosCommon.h b/RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.h new file mode 100644 index 0000000000..b63d2bfd2c --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_2_0/Common/BiosCommon.h @@ -0,0 +1,31 @@ +/** @file + + Redfish feature driver implementation - internal header file + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> + Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_BIOS_COMMON_H_ +#define EFI_REDFISH_BIOS_COMMON_H_ + +#include <RedfishJsonStructure/Bios/v1_2_0/EfiBiosV1_2_0.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 "2" +#define RESOURCE_SCHEMA_ERRATA "0" +#define RESOURCE_SCHEMA_VERSION "v1_2_0" +#define REDPATH_ARRAY_PATTERN L"/Bios/.*" +#define REDPATH_ARRAY_PREFIX L"/Bios/" +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish-Bios.v1_2_0" + +#endif diff --git a/RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.c b/RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.c new file mode 100644 index 0000000000..484c8e40f0 --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.c @@ -0,0 +1,823 @@ +/** @file + Redfish feature driver implementation - Bios + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + 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 ((REDFISH_DEBUG_TRACE, "%a: provisioning in %s mode\n", __FUNCTION__, (PostMode ? L"POST" : L"PATCH"))); + + Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (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; + EFI_STRING PendingSettingUri; + REDFISH_RESPONSE PendingSettingResponse; + REDFISH_RESPONSE *ExpectedResponse; + CHAR8 *Etag; + + if ((This == NULL) || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (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; + } + + // + // Check and see if "@Redfish.Settings" exist or not. + // + ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); + Status = GetPendingSettings ( + Private->RedfishService, + Response.Payload, + &PendingSettingResponse, + &PendingSettingUri + ); + if (!EFI_ERROR (Status)) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __FUNCTION__, PendingSettingUri)); + Private->Uri = PendingSettingUri; + ExpectedResponse = &PendingSettingResponse; + } else { + Private->Uri = Uri; + ExpectedResponse = &Response; + } + + Private->Payload = ExpectedResponse->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 (ExpectedResponse, &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) { + if (Response.Payload != NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + } + + if (PendingSettingResponse.Payload != NULL) { + RedfishFreeResponse ( + PendingSettingResponse.StatusCode, + PendingSettingResponse.HeaderCount, + PendingSettingResponse.Headers, + PendingSettingResponse.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_PROTOCOL (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_PROTOCOL (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_PROTOCOL (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_PROTOCOL (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_PROTOCOL (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_PROTOCOL (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) { + DEBUG ((DEBUG_ERROR, "%a: no Redfish service configured\n", __FUNCTION__)); + 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: %s 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_2_0/Dxe/BiosDxe.inf b/RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.inf new file mode 100644 index 0000000000..3493922cea --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_2_0/Dxe/BiosDxe.inf @@ -0,0 +1,55 @@ +## @file +# INF for Redfish feature driver - Bios +# +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR> +# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# 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 + RedfishAddendumLib + +[Protocols] + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED + gEdkIIRedfishFeatureProtocolGuid ## CONSUMED + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Depex] + TRUE -- 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100594): https://edk2.groups.io/g/devel/message/100594 Mute This Topic: https://groups.io/mt/97315343/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-